- Posts: 141
COMMUNITY FORUM
How to limit related items to a category?
- Gorast
-
Topic Author
- Offline
- Premium Member
I need to relate Actor to its Performance. I do this by tags. The problem is that other actors that have same performance show in the related items. How can I limit related items to show related items ONLY from category Performances?
Thanks,
Gorast
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
In the meantime, your best bet is to simply override the itemlist.php model in the frontend (function getRelatedItems()) and simply extend with your rules.
Please Log in or Create an account to join the conversation.
- Gorast
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Never learned how really Joomla draw the id for the categories.
Please Log in or Create an account to join the conversation.
- JoomlaWorks
-
- Offline
- Admin
- Posts: 6227
Please Log in or Create an account to join the conversation.
- Gorast
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Easy for you to say. I'll try to find my way around or I'll wait for the upcoming release :D
Thanks.
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
$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 = {$itemID}) GROUP BY t.itemID";
If it works with you, I can help to implement this feature in the upcoming release.
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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
Gorast wrote: Should I run this in phpMyAdmin?
No, you will modify itemlist.php model in the frontend as Fotis said
You will replace this line:
$query = "SELECT itemID FROM #__k2_tags_xref WHERE tagID IN ({$sql}) AND itemID!={$itemID} GROUP BY 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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Tnx,
Gorast
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
The query I detects the category id from the item being viewed.
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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
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
-
- Offline
- Platinum Member
- Joomla Developer
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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Is that it?
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
$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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
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
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
$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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Thanks!
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
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
-
Topic Author
- Offline
- Premium Member
- Posts: 141
Please Log in or Create an account to join the conversation.