Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 602 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get sibling categories in category.tpl for the current category in prestashop

#1
I need to list **sibling categories** in the category page in a Prestashop theme. Currently it **does** show the sub-categories if any but **not** the sibling categories.


A quick answer would really be appreciated! Thanks.
Reply

#2
For to start i would have created a override file in /override/controllers/, named CategoryController.php

And add this:

<?php

class CategoryController extends CategoryControllerCore
{
public function displayContent()
{
// Get the global smarty object.
global $smarty;

// Get current category's parent.
$parent_category = new Category($this->category->id_parent, self::$cookie->id_lang);

// Get parent category's subcategories (which is current category's siblings, including it self).
$category_siblings = $parent_category->getSubCategories((int)self::$cookie->id_lang)

/* Assign your siblings array to smarty. */
$smarty->assign(
array(
"category_siblings" => $category_siblings
)
);

/* This we run the normal displayContent, but pass the siblings array to
category.tpl */
parent::displayContent();
}
}

?>

I this the basic way to do it, i have not tested it get. You need to find a way to not list current category in the list of siblings.

If the code works you will now have an array in category.tpl named category_siblings, you now need to for example copy the code in category.tpl that outputs the subcategories and replace the subcategories arra with the category_siblings array.
Reply

#3
Thank you - works great!

You don't have to remove current category from array, intead just mark it as active. You have to edit category.tpl and in foreach subcategories loop insert:

<li {if $category->id == $subcategory.id_category}class="active"{/if}>

Its very nice navigation hack! Thanks one more time
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through