Keyword

SOLVED --- Showing tagged items in item view?

  • Bam Bam
  • Bam Bam's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago - 7 years 10 months ago #154021 by Bam Bam
Hello everybody,

I hope you can help me. I'd like to view all tagged items with a special tag (the whole article) in an item view under the the content without a module. E.g. all articles with "tag1" under the content of "item1", all articles with "tag2" under the content of "item2" ... and so on.
I tried to do this with a mySQL - Query but I can't find the setted tags in the k2_items table anywhere.

Has anyone a idea how to do this?

Kind regards Matthew.
Last edit: 7 years 10 months ago by Bam Bam.

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

  • Bam Bam
  • Bam Bam's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago - 7 years 10 months ago #154026 by Bam Bam
Replied by Bam Bam on topic SOLVED --- Showing tagged items in item view?
Found out a solution on my own. If anyone ist interested I used this code:
<?php	$tag_title = $this->item->title;
		$db_abfrage=JFactory::getDBO();
		$db_abfrage->setQuery("SELECT c.`tagID`, c.`itemID`, ca.`name`, ca.`id`, cb.`id`, cb.`title`, cb.`introtext` FROM #__k2_tags AS ca, #__k2_tags_xref AS c, #__k2_items AS cb WHERE ca.`name` = '$tag_title' AND ca.`id` = c.`tagID` AND c.`itemID` = cb.`id`");
		$db_abfrage_result = $db_abfrage->loadObjectList();
		foreach($db_abfrage_result as $db_tags) {
			echo '<h3>'.$db_tags->title.'</h3><br />';
			echo '<img src="media/k2/items/cache/'.md5('Image'.$db_tags->id).'_S.jpg" /><br />';
			echo $db_tags->introtext.'<br />';
		}
?>
I just wanted to show all articles tagged with the item title, listed under the content of the active article / item with the same title.
Background was a listing of different firms. When getting the infos of the firm in item view there should be all articles tagged with the firm name shown under the main info of the firm.

Sorry for my bad explanation. Maybe anyone can use this, too.

Matthew.
Last edit: 7 years 10 months ago by Bam Bam.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 10 months ago #154077 by Krikor Boghossian
Replied by Krikor Boghossian on topic SOLVED --- Showing tagged items in item view?
Kudos Matthew,

Seems like a nice solution. Remember to use overrides instead of applying this directly to core files.

getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Bam Bam
  • Bam Bam's Avatar Topic Author
  • Offline
  • Senior Member
More
7 years 10 months ago #154270 by Bam Bam
Replied by Bam Bam on topic SOLVED --- Showing tagged items in item view?
Thanks for the hint. Overrides are one reason I like to work with K2: you can simply display all the things you want in the order you want with custom overrides... ;) Top! :)

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


Powered by Kunena Forum