Using tolinks in a Tpl called by getResourcesTag and multiple tag values are returned (as required) but as one link / string with no spaces or commas.
This is the Tpl
[[tolinks? &items=`[[+BlogCat]]` &tagRequestParam=`tag` &inputDelim=`||` &outputDelim=`, ` &target=`202` &tagKey=`BlogCat` &useTagsFurl=`0`]]
Working fine on another site.
MODX 3.1.2
PHP 8.3
Would be grateful if anybody has ideas?
So what is the actual value of the [[+BlogCat]] placeholder, if you output it directly (without calling toLinks)?
Are the values indeed separated by double pipes (&inputDelim=`||`)?
[[+BlogCat]] = Your Community NewsOur Team.
Values are separated by double pipes - it’s a MultiSelect Listbox
I’m a bit confused. You say the values are separated by double pipes, but where are the double pipes in “Your Community NewsOur Team”?
It might be that the values are separated by double pipes in the database table, but the input for the toLinks snippet that you provide with the &items property doesn’t seem to have a separator.
It seems getResourcesTag doesn’t get the raw value for the TV, but processes it. Maybe try using a different Output Option/Output Type for the TV “BlogCat” if possible (or use a different value for the processTVs property in the getResourcesTag call).
If I output as a String, the double pipes appear and the output through toLinks is: Tags: Our Team, Your Community News
…but when clicking on a tag, even though the URI looks right (.uk/news?tag=Our+Team&key=BlogCat) the results don’t filter.
So what happens on the “news” site?
Do you call getResourcesTag?
Are the values for the properties correct (tagKey, tagRequestParam) to correspond to the URL (.../news?tag=Our+Team&key=BlogCat)?
Firstly - thanks Harry. I (you!) seem to have ‘fixed’ this. After much trial and error I changed my MultiSelect TV (BlogCat) Output to a Delimiter with a value of: , (Comma). This worked but I also reinstalled the TagLister snippet and copied all chunks over from the other working site. The other site works with the output Delimiter set to ‘default’. The two sites are on different server environments so it’s go to be something to do with that.
If it helps anybody else, I’m calling a bunch of news articles from a Collection.
The ‘News Overview’ Template contains this to get a dropdown list of all categories…
[[!tagLister? &tv=`BlogCat` &tvDelimiter=`||` &tpl=`tagCatTpl` &target=`202`]]
Also the following to get the individual news articles previews…
[[!getResourcesTag?
&parents=`202`
&showHidden=`1`
&limit=`10`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
&sortby=`publishedon`
&sortdir=`DESC`
&pageVarKey=`page`
&tpl=`newsCallOutTpl`]]
The newsCallOutTpl contains this to list and filter the tags…
[[!tolinks?
&items=`[[+BlogCat]]`
&tagRequestParam=`tag`
&outputDelim=`,`
&tpl=`tagex`
&target=`[[*id]]`
&tagKey=`BlogCat`
&useTagsFurl=`0`
&processTVs=`0`
]]
The ‘tagex’ tpl for each tag link contains this…
<li class="[[+cls]]"><a href="[[+url]]">[[+item]]</a></li>
toLinks doesn’t have a &processTVs property! This snippet doesn’t query any data. It just uses what’s provided with &items.
getResourcesTag is a wrapper for getResources and queries the TV values.
To avoid having to set an output delimiter for the TV (and get the raw TV value instead), you could set processTVs to 0 here, or if you need other TVs to be processed, use the property processTVList and don’t include “BlogCat” in the list.
Also in general, I’d recommend using Tagger for new sites instead of tagLister.
The way tagLister stores the data (as TV values) and the way getResourcesTag queries the tags, makes the process slow and unreliable. Especially if tags are similar or contain the same words.
Yep I understand what you’re saying - I made a mistake there in toLinks with processTVs.
In getResourcesTag, if I set processTVs to positive - it just outputs the tags with double pipe delimiters between them.