Test the value of the metadata system tags

alicia.persaud's Avatar


11 May, 2010 02:28 PM

In the page templates, is there a way to test the metadata system tags (e.g. <system-page-keywords/>) to determine if the page's meta fields (e.g. keywords) has a value or not?

And if it doesn't have a value (it's empty), is there a way to access the site's Global Keywords (under Tools >Preferences>Content) and output them on the page template instead?

  1. Support Staff 1 Posted by Tim on 11 May, 2010 07:45 PM

    Tim's Avatar

    Hi Alicia,

    There is no way to insert logic in a Template which will swap out certain metadata tags when values for a tag do not exist. You should be able to accomplish this with one system region, however. Try doing something like this:

    • Create a new system region in your Template where you need to output this data (I'm assuming in the <head> tag). For example, your region might be named something like this: <system-region name="keywords"/>
    • Attach a 'current-page' index block to this region so that you have access to the page's metadata. A 'current-page' index block is just an index block that returns information for the current page only.
    • Create an XSLT or Velocity Format to step through the index block and output the keywords on the page.

    You could easily add some logic in your Format to determine whether or not keywords exist in the XML returned by the index block. If you have a list of keywords for your site handy, you could even create a variable in your Format and have those inserted as keywords should the page not have any keywords. This, of course, would mean that the Format would need to be maintained if you plan on changing keywords often.

    If you don't want to go this route, you could potentially make the Keywords field required for users. This would force them to either enter keywords for the asset or select from the Global Keywords defined in your Content Preferences.

    Hope this helps!

  2. Tim closed this discussion on 11 May, 2010 07:45 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac