Keyword

Extract tag id in tag view list

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128161 by theD “android3dgame” Waterfly
Extract tag id in tag view list was created by theD “android3dgame” Waterfly
Hello. Tell me how to get the name or id of the tag in the output template tag.
Or help set up the sql query. Thank you.

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128162 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list
why doesn't this?
Log in  or Create an account to join the conversation.

More
11 years 2 weeks ago #128163 by Lefteris
Replied by Lefteris on topic Re: Extract tag id in tag view list
Hi. You can get the tag from the URL variable:
<?php echo JRequest::getVar('tag'); ?>

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128164 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list
Thank you very much. Your solution helped bring the tag name. Now how can I get the tag id?

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128165 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list
I created a column with the name of the image in the database _k2_tags how to get out of it is in the template tag.php

Please Log in or Create an account to join the conversation.

More
11 years 2 weeks ago #128166 by Lefteris
Replied by Lefteris on topic Re: Extract tag id in tag view list
I don't get the your last message. What you want to do. You should not alter the K2 database tables on your own as this might break your site.

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago - 11 years 2 weeks ago #128167 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list

Lefteris Kavadas wrote: I don't get the your last message. What you want to do. You should not alter the K2 database tables on your own as this might break your site.

ok, but how to get the id of the tag in the tag.php?

Please Log in or Create an account to join the conversation.

More
11 years 2 weeks ago #128168 by Lefteris
Replied by Lefteris on topic Re: Extract tag id in tag view list
Unfortunately it is not available in the view. You will have to query the database:
<?php
$db = JFactory::getDBO();
$tag = JRequest::getString('tag');
$sql = "SELECT id FROM #__k2_tags WHERE name=".$db->Quote($tag);
$db->setQuery($sql, 0, 1);
$tagId = $db->loadResult();
?>

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128169 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list
Thank you very much!

Please Log in or Create an account to join the conversation.

  • theD “android3dgame” Waterfly
  • theD “android3dgame” Waterfly's Avatar Topic Author
  • Offline
  • New Member
More
11 years 2 weeks ago #128170 by theD “android3dgame” Waterfly
Replied by theD “android3dgame” Waterfly on topic Re: Extract tag id in tag view list

Lefteris Kavadas wrote: Unfortunately it is not available in the view. You will have to query the database:

<?php
$db = JFactory::getDBO();
$tag = JRequest::getString('tag');
$sql = "SELECT id FROM #__k2_tags WHERE name=".$db->Quote($tag);
$db->setQuery($sql, 0, 1);
$tagId = $db->loadResult();
?>

Tell me how this method to get two variables from a db. $tagId and $tagname?

Please Log in or Create an account to join the conversation.

More
11 years 1 week ago #128171 by Lefteris
Replied by Lefteris on topic Re: Extract tag id in tag view list
<?php
$db = JFactory::getDBO();
$tag = JRequest::getString('tag');
$sql = "SELECT id, name FROM #__k2_tags WHERE name=".$db->Quote($tag);
$db->setQuery($sql, 0, 1);
$row = $db->loadObject();
?>

Now the $row is an object variable with two properties, the id and the name.

Please Log in or Create an account to join the conversation.