On a blog/news page I want to show related articles using the Tagger extra. (ModX 2.7.3, newest versions of extra’s)
So I have taggerGetTags fetch the tags for the current resource in taggerGetResourcesWhere in pdoResources tags as follows:
1248 is the id of the newspages container.
This shows articles with similar tags, that’s working ok. But I don’t want to show the current article in the related articles.
I tried
&parents=1248, -[[*id]], &resources=-[[*id]], &exclude=-[[*id]]
all not working, ie. the current article is not excluded.
should normally work, but it seems that with the use of
&where=`[[!TaggerGetResourcesWhere? ... ]]`
the condition to exclude the resource gets deleted (somewhere here in the code).
Probably the easiest way for you to get the desired result is therefore to make a change to the snippet TaggerGetResourcesWhere:
Duplicate the snippet and give it a new name like TaggerGetResourcesWhereExcludeCurrentResource. Then add this line at the end of the snippet code right before the return- statement.
@bruno17 Thank you! and @halftrainedharry too of course for answering.
TaggerGetRelatedWhere does exactly what I need, moreover it doesn’t return random results when the current resource has no tags, which was another problem I had to tackle.
This snippet should definitely be added to the docs on docs.modx.com.