- Posts: 41
COMMUNITY FORUM
SOLVED - Display category name in tag.php
- alexandria
-
Topic Author
- Offline
- Senior Member
Less
More
10 years 3 months ago - 10 years 3 months ago #135658
by alexandria
SOLVED - Display category name in tag.php was created by alexandria
Hello,
I have a module k2 tool cloud pointing to a subcategory 'sports"
when i click on "snowboard" tag, i want 'sports' to display before the title tag "snowboard' and all the items.
I tried :
It works but it's not very good, maybe there is something simple than that
can you please help me for this ?
Thanks
I have a module k2 tool cloud pointing to a subcategory 'sports"
when i click on "snowboard" tag, i want 'sports' to display before the title tag "snowboard' and all the items.
I tried :
<?php foreach($this->items as $item): ?>
<?php $parentName = $item->category->parent; ?>
<?php endforeach; ?>
<?php // show id for help)
echo $parentName; ?>
<?php if ($parentName == 4)
echo "sports";
?>
It works but it's not very good, maybe there is something simple than that
can you please help me for this ?
Thanks
Last edit: 10 years 3 months ago by alexandria.
Please Log in or Create an account to join the conversation.
- alexandria
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 41
10 years 3 months ago #135666
by alexandria
Replied by alexandria on topic Display category name in tag.php
Finally i will write the name of the parent category inside the description of the child category like this :
and write this in tag.php :
<h3>Sports</h3>
and write this in tag.php :
<?php foreach($this->items as $item): ?>
<?php $parentCatName = $item->category->description; ?>
<?php endforeach; ?>
<header>
<?php echo $parentCatName; ?>
<h3><?php echo $this->escape($this->params->get('page_title')); ?></h3>
</header>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
10 years 3 months ago #135673
by Krikor Boghossian
Replied by Krikor Boghossian on topic Display category name in tag.php
You can also map the tag into a menu item under sports and use breadcrumbs. This way you will have the /sports/snowboard in your site and in your URLs.
Please Log in or Create an account to join the conversation.
- alexandria
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 41
10 years 3 months ago #135684
by alexandria
Replied by alexandria on topic Display category name in tag.php
Wow i haven't even thought about breadcrumb module, i had already set a menuitem but i didn"t know menuitems have to be under the good parent link to show correctly in the breadcrumb, i learned something.
But i badly explained at first that my category is like that : sports/winter/snowboard, it's why i have so much problems to catch the parent category.
Only one problem i see, its some tags are cities, so i have to copy the same tags under a lot of subcategories in the menu but despite that, breadcrumb seems the best way to go and it will free me to use the 'description' category.
Thanks Krikor, it helps a lot.
But i badly explained at first that my category is like that : sports/winter/snowboard, it's why i have so much problems to catch the parent category.
Only one problem i see, its some tags are cities, so i have to copy the same tags under a lot of subcategories in the menu but despite that, breadcrumb seems the best way to go and it will free me to use the 'description' category.
Thanks Krikor, it helps a lot.
Please Log in or Create an account to join the conversation.
- alexandria
-
Topic Author
- Offline
- Senior Member
Less
More
- Posts: 41
10 years 3 months ago - 10 years 3 months ago #135686
by alexandria
Replied by alexandria on topic Display category name in tag.php
I was wrong, i don"t have to copy the same tags of cities in every submenu , i have to place them under the parent link ahead like news
then breadcrumb show news/sports/winter/Mexico
Its even better!
Thanks again :)
PS : Talked too fast,
It show only news/Mexico
i have to link to Sports menuitem and it show news/sports/Mexico like you said Krikor, and it's good
:)
then breadcrumb show news/sports/winter/Mexico
Its even better!
Thanks again :)
PS : Talked too fast,
It show only news/Mexico
i have to link to Sports menuitem and it show news/sports/Mexico like you said Krikor, and it's good
:)
Last edit: 10 years 3 months ago by alexandria.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- User
Less
More
10 years 3 months ago #135769
by Krikor Boghossian
Replied by Krikor Boghossian on topic Display category name in tag.php
Glad to hear that it is solved :)
Please Log in or Create an account to join the conversation.