Skip to content

Commit

Permalink
Merge pull request #9282 from Devportobello/menuItemAttrRel
Browse files Browse the repository at this point in the history
[SEO] rel attribute for external url menu item
  • Loading branch information
wilsonge committed Mar 3, 2016
2 parents 83cda46 + 3d35139 commit f07003c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
20 changes: 20 additions & 0 deletions administrator/components/com_menus/models/forms/item_url.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
type="text" label="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC" />

<field name="menu-anchor_rel" type="list"
label="COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL"
description="COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC"
default=""
>
<option value="">JNONE</option>
<option value="alternate">COM_MENUS_FIELD_VALUE_ALTERNATE</option>
<option value="author">COM_MENUS_FIELD_VALUE_AUTHOR</option>
<option value="bookmark">COM_MENUS_FIELD_VALUE_BOOKMARK</option>
<option value="help">COM_MENUS_FIELD_VALUE_HELP</option>
<option value="license">COM_MENUS_FIELD_VALUE_LICENSE</option>
<option value="next">COM_MENUS_FIELD_VALUE_NEXT</option>
<option value="nofollow">COM_MENUS_FIELD_VALUE_NOFOLLOW</option>
<option value="noreferrer">COM_MENUS_FIELD_VALUE_NOREFERRER</option>
<option value="prefetch">COM_MENUS_FIELD_VALUE_PREFETCH</option>
<option value="prev">COM_MENUS_FIELD_VALUE_PREV</option>
<option value="search">COM_MENUS_FIELD_VALUE_SEARCH</option>
<option value="tag">COM_MENUS_FIELD_VALUE_TAG</option>
</field>

<field name="menu_image" type="media"
label="COM_MENUS_ITEM_FIELD_MENU_IMAGE_LABEL"
description="COM_MENUS_ITEM_FIELD_MENU_IMAGE_DESC" />
Expand Down
14 changes: 14 additions & 0 deletions administrator/language/en-GB/en-GB.com_menus.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ COM_MENUS_ITEM_FIELD_ANCHOR_CSS_DESC="An optional, custom style to apply to the
COM_MENUS_ITEM_FIELD_ANCHOR_CSS_LABEL="Link CSS Style"
COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_DESC="An optional, custom description for the title attribute of the menu hyperlink."
COM_MENUS_ITEM_FIELD_ANCHOR_TITLE_LABEL="Link Title Attribute"
COM_MENUS_ITEM_FIELD_ANCHOR_REL_DESC="An optional, custom rel attribute to get more information about the menu hyperlink (search engines purpose)."
COM_MENUS_ITEM_FIELD_ANCHOR_REL_LABEL="Link Rel Attribute"
COM_MENUS_FIELD_VALUE_ALTERNATE="Alternate"
COM_MENUS_FIELD_VALUE_AUTHOR="Author"
COM_MENUS_FIELD_VALUE_BOOKMARK="Bookmark"
COM_MENUS_FIELD_VALUE_HELP="Help"
COM_MENUS_FIELD_VALUE_LICENSE="License"
COM_MENUS_FIELD_VALUE_NEXT="Next"
COM_MENUS_FIELD_VALUE_NOFOLLOW="Nofollow"
COM_MENUS_FIELD_VALUE_NOREFERRER="Noreferrer"
COM_MENUS_FIELD_VALUE_PREFETCH="Prefetch"
COM_MENUS_FIELD_VALUE_PREV="Prev"
COM_MENUS_FIELD_VALUE_SEARCH="Search"
COM_MENUS_FIELD_VALUE_TAG="Tag"
COM_MENUS_ITEM_FIELD_ASSIGNED_DESC="Shows which menu the link will appear in."
COM_MENUS_ITEM_FIELD_ASSIGNED_LABEL=" Menu"
COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE="- No association -"
Expand Down
1 change: 1 addition & 0 deletions modules/mod_menu/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public static function getList(&$params)
$item->title = htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8', false);
$item->anchor_css = htmlspecialchars($item->params->get('menu-anchor_css', ''), ENT_COMPAT, 'UTF-8', false);
$item->anchor_title = htmlspecialchars($item->params->get('menu-anchor_title', ''), ENT_COMPAT, 'UTF-8', false);
$item->anchor_rel = htmlspecialchars($item->params->get('menu-anchor_rel', ''), ENT_COMPAT, 'UTF-8', false);
$item->menu_image = $item->params->get('menu_image', '') ?
htmlspecialchars($item->params->get('menu_image', ''), ENT_COMPAT, 'UTF-8', false) : '';
}
Expand Down
5 changes: 3 additions & 2 deletions modules/mod_menu/tmpl/default_url.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Note. It is important to remove spaces between elements.
$class = $item->anchor_css ? 'class="' . $item->anchor_css . '" ' : '';
$title = $item->anchor_title ? 'title="' . $item->anchor_title . '" ' : '';
$rel = $item->anchor_rel ? 'rel="' . $item->anchor_rel . '" ' : '';

if ($item->menu_image)
{
Expand All @@ -30,11 +31,11 @@
switch ($item->browserNav) :
default:
case 0:
?><a <?php echo $class; ?>href="<?php echo $flink; ?>" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
?><a <?php echo $class; ?>href="<?php echo $flink; ?>" <?php echo $title . $rel; ?>><?php echo $linktype; ?></a><?php
break;
case 1:
// _blank
?><a <?php echo $class; ?>href="<?php echo $flink; ?>" target="_blank" <?php echo $title; ?>><?php echo $linktype; ?></a><?php
?><a <?php echo $class; ?>href="<?php echo $flink; ?>" target="_blank" <?php echo $title . $rel; ?>><?php echo $linktype; ?></a><?php
break;
case 2:
// Use JavaScript "window.open"
Expand Down

0 comments on commit f07003c

Please sign in to comment.