Jump to content

name of category in title of product page


Recommended Posts

Hello to everybody

I want that the <title> of a product page also shows the category (and subcategorys) of that product.

I think that the easiest way to achieve this is to get the breadcrumb and show it in the <title>, but I don't know how to do it

Could anybody help me?
Thanks

Link to comment
Share on other sites

Hello to everybody

I want that the <title> of a product page also shows the category (and subcategorys) of that product.

I think that the easiest way to achieve this is to get the breadcrumb and show it in the <title>, but I don't know how to do it

Could anybody help me?
Thanks


Which version of prestashop 1.4 or earlier?

I did something similar for 1.4 but be prepared for touching the core files.

Cheers
Link to comment
Share on other sites

Make sure you get all the categories till the root level (you probably do not want to display the root title), and make them available in your tpl

In classes/Category.php there're 2 key variables for doing that:


/** @var integer Parent category ID */
public $id_parent;

/** @var integer Parents number */
public $level_depth;

Hope it helps

Link to comment
Share on other sites

Make sure you get all the categories till the root level (you probably do not want to display the root title), and make them available in your tpl

In classes/Category.php there're 2 key variables for doing that:


/** @var integer Parent category ID */
public $id_parent;

/** @var integer Parents number */
public $level_depth;

Hope it helps


jaimemm please I need more information:
-To start, i don't know the file where the <title> is set.
-Which tpl are you talking about?
-What I should do with these two variables that are you talking about?

Thanks
Link to comment
Share on other sites

-To start, i don’t know the file where the <title> is set.

When you say tittle are you talking about the "name" of the category or the SEO "title" for the category?
Both are properties of the category.

In the tpl (I think is product.tpl), you have to get that variable.

-Which tpl are you talking about?

I think is product.tpl (copy your theme folders and play around)

-What I should do with these two variables that are you talking about?

get every level_depth-1 categories ,and put into an array the name of each of them
id_parent will be necessary to find the parent category.

quickly,something like:

counter=0;
array names;
while counter < level_depth-1 do
{

names[counter]=catAux.name;
catAux=catAux.getParent(id_parent);
counter++;
}

Hope it helps

Link to comment
Share on other sites

×
×
  • Create New...