xertion Posted July 7, 2013 Share Posted July 7, 2013 We have a blockcategories menu with about 400 categories total including all the subcategories, and this is creating too many links on each of our page, resulting in not-optimal onpage SEO. I want to add rel="nofollow" and some Javascript to all links except the root and the selected category and it's children and siblings. Example: - Subcategory A (Root, dofollow) - Subcategory A-1(Sibling of selected, dofollow) - Subcategory A-2 (Selected, dofollow) - Subcategory A-2-a (Child of selected, dofollow) - Subcategory A-2-b (Child of selected, dofollow) - Subcategory A-2-c (Child of selected, dofollow) - Subcategory A-3 (Sibling of selected, dofollow) - Subcategory B (Root, dofollow) - Subcategory B-1 (Nofollow) - Subcategory B-2 (Nofollow) - Subcategory B-2-a (Nofollow) - Subcategory B-2-b (Nofollow) - Subcategory B-3 (Nofollow) - Subcategory C (Root, dofollow) - Subcategory D (Root, dofollow) I have been successful with Selecting the Root, the Selected and the Children of the selected. However I've been unsuccessful with selecting the Siblings of the selected (That share the same Parent). How do I Select the Siblings of the Selected Category within the Blockcategories .tpl files? Link to comment Share on other sites More sharing options...
Umar Akram Posted October 7, 2013 Share Posted October 7, 2013 PrestaShop is using a nested set model to store its categories: http://www.fliquidstudios.com/2008/12/23/nested-set-in-mysql/ http://en.wikipedia.org/wiki/Nested_set_model This allows you to easily select a part of the tree (parents, children, siblings, etc.). Each "Category" object has a nleft and nright member that will help you to perform these selections. Another easier way is to use the level_depth member, all siblings will have an identical level_depth value. You can modify the blockcategories.php file to add level_depth in the SELECT statement of hookLeftColumn(). Then in the category-tree-branch.tpl file, simple add a test: {if $node.level_depth == ....}rel="nofollow"{/if} Be careful, Google might not like the fact that one some pages a category is nofollow and dofollow on other pages. Link to comment Share on other sites More sharing options...
Recommended Posts