Keyword

Select articles by one tag: query to the database

  • rawling
  • rawling's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 4 months ago #128773 by rawling
joomla 3.3 and K2 2.6.8
Please, help my create a query to the database "SELECT ..."
I need to select all K2 articles by one tag named "news", tag id=5
Please urgently help my

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

More
10 years 4 months ago #128774 by Lefteris
Hi. Are you familiar with PHP programming? Even if i give you the query you would have to develop a module or a plugin to use it. You can create a menu link to a tag. This will give you a list of the items for the tag you have selected.

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

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

  • rawling
  • rawling's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 4 months ago - 10 years 4 months ago #128775 by rawling
Thanks,
I'm not a professional programmer, but I can understand any code.
I know how to make a menu for the k2 tags, but I need another: I just want sql query to the database: select all K2 materials by only one tag by only tag id - tag named "news", tagID=5

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

More
10 years 4 months ago #128776 by Lefteris
Try this:
SELECT i.*, c.name as categoryname,c.id as categoryid, c.alias as categoryalias, c.params as categoryparams 
  FROM #__k2_items as i RIGHT JOIN #__k2_categories AS c 
  ON c.id = i.catid 
  WHERE i.published = 1 
  AND i.access IN(1,1) 
  AND i.trash = 0 
  AND c.published = 1 
  AND c.access IN(1,1) 
  AND c.trash = 0 
  AND c.language IN ('en-GB','*') 
						
  AND i.language IN ('en-GB','*') 
  AND ( i.publish_up = '0000-00-00 00:00:00' OR i.publish_up <= '2014-05-28 08:50:43' ) 
  AND ( i.publish_down = '0000-00-00 00:00:00' OR i.publish_down >= '2014-05-28 08:50:43' ) 
  AND i.id IN (SELECT itemID 
  FROM #__k2_tags_xref 
  WHERE tagID=5) 
  ORDER BY i.id DESC 
  LIMIT 0, 10
Note that this will give you just the raw data from the database.

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

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

More
10 years 4 months ago #128777 by Lefteris
Also note that some values in this query like language, access, date are computed during runtime. You will have to build the query with PHP so these values are correct.

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

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

  • rawling
  • rawling's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 4 months ago #128778 by rawling
Dear Lafteris Kavadas, very big thank you for your help!

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

More
10 years 4 months ago #128779 by Lefteris
You are welcome.

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

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


Powered by Kunena Forum