Jump to main content Jump to doc navigation

Converts a delimited list into a list of linkable tags: typically, this would be used on a page that has been tagged with various taxonomical tags and you want to link to other pages that have been tagged by those same tags. For an example, see https://forums.modx.com/index.php/topic,61744.0/topicseen.html


tolinks is called with the normal snippet tag, passing in an 'items' property as the list of items to convert; a 'target' property for the Resource to generate links to; and a 'key' property for the name of the GET param being generated on each link.


Name Example usage Description Default Value
items &items=[[*myTemplateVar]] The items to turn into links.
tpl &tpl=linkTpl Name of a Chunk that will be used for each result. link
target &target=6 The ID of the Resource that links will point to. 1
inputDelim &inputDelim=, The delimiter that is used on the items property. Defaults to a comma. ,
outputDelim &outputDelim=, The delimiter that separates the links that are outputted. Defaults to a comma. ,
tagRequestParam &tagRequestParam=tag The REQUEST var key that will be used in generating the links. tag
cls &cls=tagStyle Name of a CSS class to add to each result. tl-tag
toPlaceholder &toPlaceholder=placeholderName If set, will set the output of this snippet to this placeholder rather than output it. false
useTagsFurl &useTagsFurl=1 Is set to 1, this will force full links to each tag. false
tagKey &tagKey=articlestags tag group name, used in generating links tags
tagKeyVar &tagKeyVar=MyCustomVar sets the GET var key

I.e., [[tolinks? &tagKey=articlestags&tagKeyVar=MyCustomVar]]

outputs http://f.qdn.com/somepage?MyCustomVar=articlestags&tag=theTag\\ | key |

There is 1 chunk that is processed in tolinks. Its corresponding parameters are:

  • tpl - The Chunk to use for each link generated.


Change the TV value of 'tags' into links that point to the URL of Resource 123 with the GET param of 'tag':

[[!tolinks? &items=`[[*tags]]` &key=`tag` &target=`123`]]

Be Careful toLinks will generate relative URLs to the resource indicated by the &target parameter, so if you are having trouble getting the links to point to the correct URL, add a Chunk containing something like the following for use by the &tpl parameter: [[+item]]

Alternatively, set the &useTagsFurl property.

The resource ID referenced by the &target parameter should contain something like the following that lists the posts tagged:

    &includeContent=`1` ]]

See Also

  1. tagLister.getResourcesTag
  2. tagLister.tagLister
    1. tagLister.tagLister.all
    2. tagLister.tagLister.tpl
  3. tagLister.tolinks
    1. tagLister.tolinks.tpl

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.



$0 per month—let's make that $500!

Learn more