Comma Seperated Link Tags with Keyword Modifier


(Tbaatar) #1

Hi,

I’m trying to create a list of tags based from a Metadata Select Field. As per the Useful Keyword Replacement instructions, I’m able to split the comma separated string and wrap it in a HTML.

However, I’m unable to apply create links with each tag value.

This is what used to separate the string with anchor tag:
%asset_metadata_tagList^replace:;:</a><a>^tagif:a%

here I tried to add the link value but it just prints the entire comma separated string inside the href:
%asset_metadata_tagList^replace:;:</a><a href="./search?{asset_metadata_tagList}">^tagif:a%

I just can’t get my head around it, tried various combinations.


(Nick Papadatos) #2

So if I understand you correctly you want a list of tags tag 1, tag 2 etc and have them as hyperlinks. So if I clicked on tag 2 that filter all asset tagged with tag 2?
Have you tried the following: yourdomain.com.au/your-asset?tagcategory=Metadata_key


(Tbaatar) #3

Hi Nick,

The filter part is all sorted.
I just want to print the individual comma separated values (Apple; Orange; Banana;) from the Metadata Select Field into the href.

At the moment I can only print it like this:

<a href="">Apple</a>
<a href="">Orange</a>
<a href="">Banana</a>

But i want to be able to print the text as href as well like this

<a href="./search?Apple">Apple</a>
<a href="./search?Orange">Orange</a>
<a href="./search?Banana">Banana</a>

I know this is possible with JS, but I’m hoping it can be achieved with natively from Squiz.


(Peter McLeod) #4

Hi

If you have access to a Matrix version that has server side JS then you might be best to use this to split the tags into an array and iterate over them.

Not sure if there is a simple way using keywords to do what you are wanting.

Other option might be to use xslt keyword - but server side js would be simpler.

XSLT example:

%asset_metadata_tagList^tagif:tags^replace:; :</tag><tag>^xslt:123^stripdecl%

Edit should be:
%asset_metadata_tagList^tagif:tag^tagif:tags^replace:; :</tag><tag>^xslt:123^stripdecl%

with you xslt file (id 123) being something like this:

<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><xsl:for-each select="tags/tag">
<a><xsl:attribute name="href">./?a=456?query=<xsl:value-of select="@id"/><xsl:value-of select="." /></a>
</xsl:for-each></xsl:template></xsl:stylesheet>

Thanks
Peter


(Tbaatar) #5

Hi Peter,

Thanks for the suggestion.
I will take a look into both solution.

Many thanks,
Tuguldur


(Nick Papadatos) #6

I did what something similar to what Peter suggested but with a little jQuery


(Tbaatar) #7

I have it working with simple JQuery but wanted to achieve it with pure Matrix.


(Nick Papadatos) #8

One last thing - how about an asset listing page and use Group Format?
<option value="./search?%asset_metadata_tagList%">%group_name%</option>
Then in your Asset Grouping metadata field select the metadata schema (tagList)? That way your dropdown/select would be dynamically generated. I’m not 100% sure what what you’re trying to do but this may be an option worth investigating


(Tbaatar) #9

Asset listing might be a possible solution but the page is already asset listing 3 different asset types and creating a nested asset listing to display the tags may hit on performance. In addition, it is going to be used as tag therefore we don’t really want create select option or have to create hacky CSS to display it like a tag.

Here is an image of working example, for now I have opted for 3 line of jQuery to create the links dynamically.

When the user clicks the tag, they’re taken to a tagged page that lists events that have specific metadata tag.