Best method for content tags


(Emily) #1

Matrix Version: 5.4.1

Trying to work out what is the best method for doing tagging of page content.

I have initially begun setting up with Thesaurus terms, via Metadata (as per the Tutorial suggestion). However, I am wanting to display a linked list of each term the page is tagged for at the bottom of the page. (The link per term would go to the Related Asset Listing page).

So the Metadata outputs as:

Term1, Term2, Term3

I need the effect of:

[code]

  • Term1
  • Term2
  • Term3
  • [/code]

    I can use the ^replace modifier to do this, except for the Href link.

    What is the best way to approach this?
    Is Thesaurus terms & Related Asset Listing the best approach?
    Or would I be better submitting the Href to a Search page with a GET variable? And then how to easily feed in the GET variable based on the term output in the metadata.

    I think I have been looking at this too long, and tying my mind in knots. Hoping a fresh perspective will come up with a clearer solution.

    Thanks in advance. :slight_smile:


    (Bart Banda) #2

    You could potentially control this via SSJS seeing as you are on 5.4, https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript

    But do you want each Term link to go to a different URL? Or all of them to go to the RElated Asset Listing page? It’s not clear since you are using different ./?a= links for each term, but you also say:


    (Emily) #3

    Good question, I didn’t explain that very well did I…

    I haven’t used a Related Asset Listing before (never needed to, between Asset Listing & Search Pages), so I am not sure if I can feed a variable (for the Related Term) through to it like I can a Search page.

    When clicking on the link of the Term, it would take the user to a page which has a list of all assets (of types determined by the Listing settings) that have also been tagged with that Term.

    Not sure if I need to have more than one Related Asset Listing (one per term - I hope not!) or if I can feed through in the URL the parameter of “this is the term we are looking for”.
    Or perhaps it is still easier to do this with a Search Page looking for the term in the metadata field it is applied on? (as I have done in the past)

    As for the SSJS…
    I knew I had seen a nifty code for separating out metadata outputs. I had a feeling it was from the Webinar I saw it in - but I couldn’t find the actual code yesterday when hunting in Metadata & such places. Didn’t think to look in the SSJS section of the manual: https://matrix.squiz.net/manuals/concepts/chapters/server-side-javascript#list-assets-from-a-metadata-array This is exactly what I had been trying to hunt down yesterday. :slight_smile:

    I’ll have a fiddle with this SSJS and also a closer look at the Related Asset Listing (vs Search Page method), and see about making the links go to a listing of their terms.

    Thank you once again Bart. :relieved:


    (Emily) #4

    Hiccup with the SSJS…

    It appears that Thesaurus Terms do not have an asset ID for the purpose of keyword replacements?
    i.e. ^as_asset:asset_assetid will return no result.

    However, if I use a Relate Asset metadata field, and link it to the Thesaurus Term, it will return an asset ID but does not recognise it has an asset name.
    i.e. ^as_asset:asset_name and ^as_asset:asset_attribute_name both return blank.

    Am I doing something wrong there?

    I think I will abandon using the Thesaurus, and use another asset type in its place, which will reliably return both an Asset ID and an asset name.


    (Bart Banda) #5

    I’d say this is easier, since the metadata values of the terms are just strings that you can do a search for. I’ve done this in the past with relative ease.

    Well, if you are using metadata terms, all you need to print is the metadata value of that term field on the current page right? And then feed that string value as a GET parameter to your search page?