wennerholm Posted February 9, 2014 Share Posted February 9, 2014 Hi all, I'm wondering if anyone has a clue on how one would go about adding a rel="nofollow" to subcategory links in the blocktopmenu? Since the blocktopmenu is really just a bunch of links stacked on top eachother (as far as the webcrawlers care) and then sorted out with css and js (to make sense to human users) it seems to me that I'm getting way more links on each page than what would have been ideal for SEO purposes. The subcategory links in the top menu adds something like 400 links to every page on our site, which I suspect is making search engines a bit confused as to how everything is really connected. An easy solution to this (if I could figure out how to do it) would be to add a rel="nofollow" to all of the subcategory links in the blocktopmenu module except the top links that are visible all the time (since these are actually telling the search enginges what the top menu structure looks like). I suspect I should be hunting in blocktopmenu.php since both css and js are ignored by the crawlers, but I'm not quite savvy enough to get all the way. Any input in this matter would be greatly appreciated! (I've attached an image to clarify what it is I'm trying to do...) Best regards, Victor Link to comment Share on other sites More sharing options...
NemoPS Posted February 10, 2014 Share Posted February 10, 2014 Try having a look at the getCategory() method of that module (that file). About line 680 1 Link to comment Share on other sites More sharing options...
wennerholm Posted February 12, 2014 Author Share Posted February 12, 2014 Hi, Thank you for the input, that helped a lot along the way. I've now successfully added the rel="nofollow" tag to the links in the menu, but with a slight problem. The way I've located it now (see below) it effects all of the links, even the top ones. Do you (or anyone else) have a good idea of how to apply it only to children of the "n:th order"? private function getCategory($id_category, $id_lang = false, $id_shop = false) { $id_lang = $id_lang ? (int)$id_lang : (int)Context::getContext()->language->id; $category = new Category((int)$id_category, (int)$id_lang); if ($category->level_depth > 1) $category_link = $category->getLink(); else $category_link = $this->context->link->getPageLink('index'); if (is_null($category->id)) return; $children = Category::getChildren((int)$id_category, (int)$id_lang, true, (int)$id_shop); $selected = ($this->page_name == 'category' && ((int)Tools::getValue('id_category') == $id_category)) ? ' class="sfHoverForce"' : ''; $is_intersected = array_intersect($category->getGroups(), $this->user_groups); // filter the categories that the user is allowed to see and browse if (!empty($is_intersected)) { $this->_menu .= '<li '.$selected.'>'; $this->_menu .= '<a href="'.Tools::HtmlEntitiesUTF8($category_link).'" rel="nofollow">'.$category->name.'</a>'; if (count($children)) { $this->_menu .= '<ul>'; foreach ($children as $child) $this->getCategory((int)$child['id_category'], (int)$id_lang, (int)$child['id_shop']); $this->_menu .= '</ul>'; } $this->_menu .= '</li>'; } } Link to comment Share on other sites More sharing options...
NemoPS Posted February 14, 2014 Share Posted February 14, 2014 What about targeting the level depth: $category->level_depth Link to comment Share on other sites More sharing options...
Recommended Posts