-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Tags filter for Joomla! articles #2561
base: develop
Are you sure you want to change the base?
Conversation
@Kubik-Rubik Thanks! I've been busy on other things and thus I've not had time to figure out how to integrate tags to the query. I do remember that tags were quite complicated as I did fix some issues with them years ago. Do you have reference to the code which does the same in Joomla module? I want to be sure there isn't more into it which could cause unexpected behavior when using JOIN to tags table. |
@mahagr @Kubik-Rubik @yellowwebmonkey I verified the PR right now and it does work but TBH I don't like that the feature was implemented only based on the Tag ID which is quite difficult to handle for end users. Moreover like suggested in #2534 I would love to see the option to match 1.) to filter for both (id and name) Here is the PHP code to match for tag name instead of ID (just for the sake of completeness): public function tags($tagNames= [])
{
if (empty($tagNames['name'][0])) {
return $this;
}
$tagIdsArray = array_map('intval', $tagNames['name'][0]);
$this->query->join('INNER', '#__contentitem_tag_map AS t ON t.content_item_id = a.id');
$this->query->join('INNER', '#__tags AS ta ON t.tag_id = ta.id');
return $this->where('ta.title', 'IN', $tagIdsArray)->where('t.type_alias', '=', 'com_content.article');
} |
@mahagr What unexpected behaviour do you have in mind? Actually there shouldn't be any unexpected side-effects because the tags are filtered by |
Sorry for the late reply, was too busy! I prefer the IDs more but we could add a second function for the Tag names to have both options. @thexmanxyz Or do you want to do the commit that combines it all? |
@Kubik-Rubik Don't worry! You were actually quite fast answering (~1 hour). I'm already in testing phase. I would not add a second method I will propose an update for 1.) in the next minutes. Stay tuned. I prefer to have everything within one method. Just define e.g.
But don't bother it is already implemented and working. I will add my updated version of the |
I'm currently working on Gantry 5.5, this week I've been cleaning up the code for PHP 5.6/7.1. So if you can work on this one I would appreciate. :) Can you check the code against Joomla code, to make sure we're using tags in the same way as they are? I agree that we need support for working with both tag ids and names. |
@Kubik-Rubik Can you please give me access to you fork? So that I can commit my changes directly? So I don't need to open another PR for the same thing and can directly push my changed to your repo. I would highly appreciate. |
@mahagr @Kubik-Rubik @yellowwebmonkey @N8Solutions I'm finally done with the rework. The signature of the method now looks like this (pseudo-code):
1.) First and foremost I added the functionality to filter articles for both tag 2.) Additionally I added the functionality to allow users to execute a full match against tag To clarify how this works If I have an article with the added tags If I call the This does work interchangeably with both tag Additional I had to update the Additionally I updated all Finally, I will now check within the Joomla code and the usage of tags in general but I have no doubts that this is the way to go. But I will report back when I checked that. Additionally I will update the Gantry 5 documentation (gantry/docs#196) as well to reflect the changes and new functionality. |
Let me know when you've pushed the updated code; your changes are not yet visible as I'm guessing you wanted to check it out before. |
@mahagr I know, I had to wait on @Kubik-Rubik contribution invite. The changes are now pushed to the PR. You can now verify the changes. Everything is tested and everything I changed is included within the commit fe44122 (also including code comments). |
@Kubik-Rubik @mahagr I refined the I'm now using the plurals Finally I updated the API so that we can also specify single values instead of arrays only: To support the conversion I created a method which takes care of single values / collections and converts them into an array. The routine was already used by the |
@mahagr Here are the Joomla references for using tags (with joins). This is done the same way like we are doing this:
I hope this is enough for verification. But what I noticed and what is currently missing within Gantry is Ad: |
This is so needed in Joomla! I hope after nearly 5 years this could be merge. |
This PR solves issues like #2534, #1631 and other.
Usage in the content-pro-joomla particle (as an example, use accordingly in other particles)
YAML file
Twig file (add it before the find() line(!))
Demo video: https://downloads.kubik-rubik.de/joomla/gantry5-tags-filter.mov