Get Category Parent Name

I want to change the h2/h1 tag displayed for categories, but if I change the name of the category it will change on the page and under menus. Ideally I would like to have a different menu name to the h1/h2 tag displayed on the page with the category description.



So I can have a menu structure of “Blankets → Knitted”, but the h1/h2 tag comes up with “Knitted”. Ideally I want to change the h1/h2 tag to “Knitted Blankets” and keep the menu link to just “knitted” (as it is already a sub category).



Sooo… if I use a hook to override the view, I've found I can display the current category name with {$category_data.category} and I can find the parent id with {$category_data.parent_id} but how do I fetch the name of the parent category.



Alternatively, if there is a mod out there to allow for different menu and h1/h2 tag names that would be great!



Thanks in advance!

[quote name='SeanH' timestamp='1408950320' post='190543']

I want to change the h2/h1 tag displayed for categories, but if I change the name of the category it will change on the page and under menus. Ideally I would like to have a different menu name to the h1/h2 tag displayed on the page with the category description.



So I can have a menu structure of “Blankets → Knitted”, but the h1/h2 tag comes up with “Knitted”. Ideally I want to change the h1/h2 tag to “Knitted Blankets” and keep the menu link to just “knitted” (as it is already a sub category).



Sooo… if I use a hook to override the view, I've found I can display the current category name with {$category_data.category} and I can find the parent id with {$category_data.parent_id} but how do I fetch the name of the parent category.



Alternatively, if there is a mod out there to allow for different menu and h1/h2 tag names that would be great!



Thanks in advance!

[/quote]



Please try



{$category_data.parent_id|fn_get_category_name}




Thanks

[quote name='eComLabs' timestamp='1408951413' post='190544']

Please try



{$category_data.parent_id|fn_get_category_name}




Thanks

[/quote]



Great! That worked!



Though, I would like more control over the generated h1/h2 tag. I figured I might pull the image ALT description and place it into the h1/h2 tag instead.



Any idea how to get the image ALT description? Thanks again!!!

Figured it out. FYI for anybody else, it was:



{$category_data.main_pair.detailed.alt}

I’ve tried to do something like this where I am creating a smarty/html sidebox, in that sidebox I want it to dynamically add the category name so I have the following:


{nocache}

{$category_data.parent_id|fn_get_category_name} items


Our {$category_data.parent_id|fn_get_category_name} items Include:
great item 1, great item 2,… blah blah blah…{/nocache}


This works the first time I load a category (having cleared the cache) and then it just uses that same category name where ever I go on the site… I am pretty sure it’s being cached so I tried the {nocache} tags as in the code above but nothing I try seems to be able to get the current category no matter how many pages I move through on the site.

Anyone able to help?
TIA
Mark

In your case it is required to disable cache for html blocks with smarty support in the blocks schema (app/schemas/blocks_manager/blocks.php)

eComLabs you sir are a great help thanks :slight_smile:

All sorted now.

You are welcome! :)