- Posts: 98
COMMUNITY FORUM
How to get tag name in tag itemlist?
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
I need to modificate meta titles and descriptions on tags pages.
http://mysites/news/tags/tag1
But I want to make it only using templates overrides.
How I can get tag name (variable) in template file /components/com_k2/templates/default/tag.php
Thanks.
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
-
- Offline
- Elite Member
- Posts: 169
You can create a K2 tag menu item and add the Meta Description and Keywords at the menu metadata options.
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
Teo wrote: Hi,
You can create a K2 tag menu item and add the Meta Description and Keywords at the menu metadata options.
Yes, but I still need get tag name (variable) in template, because I need to add descritption for this tag page.
My idea is to make tags pages same as categories pages.
Users should not see the difference between these pages.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Create a blank K2 categories menu item (leave the category selection empty) and call it eg: show or content, this will create the URL pattern you see there.
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
-
- Offline
- Elite Member
- Posts: 169
$tag = JRequest::getString('tag');
echo $tag;
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
Please Log in or Create an account to join the conversation.
- JoomlaWorks Support Team
-
- Offline
- Elite Member
- Posts: 169
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
$id = JRequest::getString('id');
echo $id;
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
How looks SQL query in this case?
Thanks.
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
I trying this code to get tag ID, but it does not work...
<?php
$tag = JRequest::getString('tag');
echo $tag;
$dbc=&JFactory::getDBO();
$sql="select id from k2_tags where name='".$tag."';";
$dbc->setQuery($sql);
echo $dbc;
?>
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
But I need your mind about this code.
I think it is too big to just get the ID value...
<?php
$tag = JRequest::getString('tag');
echo $tag;
$db = JFactory::getDBO();
$query = "SELECT * from #__k2_tags where name='".$tag."'";
$db->setQuery($query);
$result = $db->loadObjectList();
foreach($result as $key=>$value){
echo $value->id;
}
?>
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
- Posts: 15920
I will need some context, the query appears indeed correct.
Where did you paste it? In the top of the tag.php file or inside the loop?
Please Log in or Create an account to join the conversation.
- Roman Lipatov
-
Topic Author
- Offline
- Premium Member
- Posts: 98
I paste this code at the top.
My idea is to add new columns in k2_tags mysql table - description, meta description, meta title, icon.
So, I will be able to build tags pages, that will looks same as categories.
I think, that this feature should be a part of K2...
But right now I trying to make it with hack, and I not sure, that code above is correct, and it will not work slow (I'm not programmer).
Thanks.
Please Log in or Create an account to join the conversation.