简体   繁体   中英

Joomla 3.3 specific menu item nofollow

I want to add rel="nofollow" to certain menu items in Joomla menu. I do not want to change Joomla core files. What I want is to put in menu options nofollow for "Link Type" tab "Link Title Attribute" and then in menu overrides to check with help of php if the link has title tag and nofollow attribute in it replace it with rel="nofollow". I managed to do this with jquery, but I am afraid for some search engines not to consider jquery, so I would like to do this server side. Is there a way to get this? Thanks

If you need this only for a single (or a few) meny types, you can override the xml-file for the menu type by copying f.eks. /components/com_content/views/article/tmpl/default.xml to your template /templates/yourtemplate/html/com_content/article/default.xml (you possibly have to copy default.php as well?). Then add in a new field:

<field name="nofollow" type="radio" default="0" label="Should robots follow?"
description="">
    <option value="0">Follow</option>
    <option value="1">No follow</option>
</field>

Now override the menu module by copying /modules/mod_menu/tmpl/default_component.php to /templates/yourtemplate/html/mod_menu/ and, and there check if nofollow is true (you should be able to retrieve this value like suggested below):

if($item->params->get('nofollow', 0)) { 
// add rel="nofollow" in default_component.php 
// on lines 31 to 39, where the links are defined
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM