Keyword

How to limit related items to a category?

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 weeks ago #170165 by Gorast
Replied by Gorast on topic How to limit related items to a category?
Hey,
yes, I did modified that file. The thing is that I dont want items from same category, I want from items from specific category id number 61.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
6 years 2 weeks ago #170169 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to limit related items to a category?
In this case, you need to add the category id manually.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 weeks ago #170172 by Gorast
Replied by Gorast on topic How to limit related items to a category?
$query = "SELECT t.itemID FROM #__k2_tags_xref AS t JOIN #__k2_items AS i ON t.itemID = i.id WHERE t.tagID IN ({$sql}) AND t.itemID != {$itemID} AND i.catid = (SELECT catid FROM #__k2_items WHERE id = {61}) GROUP BY t.itemID";

Is that it?

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
6 years 2 weeks ago #170173 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to limit related items to a category?
It should be like this:
$query = "SELECT t.itemID FROM #__k2_tags_xref AS t JOIN #__k2_items AS i ON t.itemID = i.id WHERE t.tagID IN ({$sql}) AND t.itemID != {$itemID}  AND i.catid = 61 GROUP BY t.itemID";

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 weeks ago - 6 years 2 weeks ago #170174 by Gorast
Replied by Gorast on topic How to limit related items to a category?
OMG it works :D
Its not working for Parent category but if I specific the exact category it works!

Can I add another AND so another category is affected?
Like this
$query = "SELECT t.itemID FROM #__k2_tags_xref AS t JOIN #__k2_items AS i ON t.itemID = i.id WHERE t.tagID IN ({$sql}) AND t.itemID != {$itemID}  AND i.catid = 61 GROUP BY t.itemID AND i.catid = 62 GROUP BY t.itemID";

Thanks!

EDIT: Nope, its not working :D
Last edit: 6 years 2 weeks ago by Gorast.

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
6 years 2 weeks ago #170175 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to limit related items to a category?
To add multiple categories, use this version:
$query = "SELECT t.itemID FROM #__k2_tags_xref AS t JOIN #__k2_items AS i ON t.itemID = i.id WHERE t.tagID IN ({$sql}) AND t.itemID != {$itemID}  AND i.catid IN (61,62) GROUP BY t.itemID";

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 weeks ago #170176 by Gorast
Replied by Gorast on topic How to limit related items to a category?
Damn it! Imba! How can I buy you a beer?! :D
Thanks!

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
6 years 2 weeks ago #170177 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic How to limit related items to a category?

Gorast wrote: Damn it! Imba! How can I buy you a beer?! :D
Thanks!


You are welcome :)
If you want to buy me a beer, send me a message with how much you want to pay here: www.joomreem.com/contact-us

Thanks!

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
6 years 2 weeks ago #170178 by Gorast
Replied by Gorast on topic How to limit related items to a category?
Done :D

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


Powered by Kunena Forum