- Posts: 23
COMMUNITY FORUM
Select articles by one tag: query to the database
- rawling
-
Topic Author
- Offline
- Junior Member
Less
More
10 years 11 months ago #128773
by rawling
Select articles by one tag: query to the database was created 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, 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.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128774
by Lefteris
Replied by Lefteris on topic Re: Select articles by one tag: query to the database
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.
Please Log in or Create an account to join the conversation.
- rawling
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
10 years 11 months ago - 10 years 11 months ago #128775
by rawling
Replied by rawling on topic Re: Select articles by one tag: query to the database
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
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.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128776
by Lefteris
Replied by Lefteris on topic Re: Select articles by one tag: query to the database
Try this:Note that this will give you just the raw data from the database.
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
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128777
by Lefteris
Replied by Lefteris on topic Re: Select articles by one tag: query to the database
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.
Please Log in or Create an account to join the conversation.
- rawling
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 23
10 years 11 months ago #128778
by rawling
Replied by rawling on topic Re: Select articles by one tag: query to the database
Dear Lafteris Kavadas, very big thank you for your help!
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 11 months ago #128779
by Lefteris
Replied by Lefteris on topic Re: Select articles by one tag: query to the database
You are welcome.
Please Log in or Create an account to join the conversation.