link rewriting

espanae's Avatar

espanae

23 Apr, 2015 02:49 PM

How do I get the link field to rewrite itself in Velocity?

Instead of:
<meta name="thumbnail" content="http://www.union.edu/admissions/profiles/img/feature-tile/live-learn-minerva.png" /> It's rendering:
<meta name="thumbnail" content="site://reboot/admissions/profiles/img/feature-tile/live-learn-minerva.png" />

Here's my Velocity code and attached is my page XML.

#set ($thumbnail = $_XPathTool.selectSingleNode($contentRoot, '//system-page/system-data-structure/header/thumbnail/link').value'))
#if ($thumbnail)
    <meta name="thumbnail" content="${thumbnail}" />
#end

I'm running Cascade 7.12.4.

  1. 1 Posted by Wing Ming Chan on 23 Apr, 2015 04:55 PM

    Wing Ming Chan's Avatar

    Erik,

    Try something like this:

    #if ($thumbnail)
        #set( $thumbnail = "[system-asset]" + $thumbnail + "[/system-asset]" )
        <meta name="thumbnail" content="${thumbnail}" />
    #end
    

    Wing

  2. 2 Posted by Ryan Griffith on 23 Apr, 2015 06:31 PM

    Ryan Griffith's Avatar

    Hi Erik,

    To echo Wing's suggestion, here are a few alternatives, the key is to use the [system-asset] pseudo tag:

    #if ($thumbnail)
        #set( $thumbnail = "[system-asset]${thumbnail}[/system-asset]" )
        <meta name="thumbnail" content="${thumbnail}" />
    #end
    
    #if ($thumbnail)
        <meta name="thumbnail" content="[system-asset]${thumbnail}[/system-asset]" />
    #end
    

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by Wing Ming Chan on 24 Apr, 2015 12:08 PM

    Wing Ming Chan's Avatar

    Ryan,

    I tried to document this example in my site. But I had a very hard time dealing with the string literal "[system-asset]". I even turned all punctuations to unicode characters. It still did not work. Right now I just added a space between "[" and "s". How do I escape this string so that it can be displayed on a page (the string is in fact in the WYSIWYG)?

    By the way, I am very happy that the Edit button is back.

    Wing

  4. 4 Posted by Ryan Griffith on 24 Apr, 2015 01:28 PM

    Ryan Griffith's Avatar

    Hi Wing,

    Although not ideal, placing a space within the tag is definitely the best way to go. If you wish to avoid the space from appearing on the page (and when copying), we use the following on our KB:

    [<!-- -->system-asset]/path[<!-- -->/system-asset]
    

    The comment and space will cause the pseudo tag to be skipped, but because we the space is commented out, it will not appear to the user.

    Please let me know if you have any questions.

    Thanks!

  5. 5 Posted by Wing Ming Chan on 24 Apr, 2015 01:48 PM

    Wing Ming Chan's Avatar

    Ryan,

    By using a comment containing a space? What a funny way! But thank you for the info.

    Wing

  6. 6 Posted by Ryan Griffith on 24 Apr, 2015 02:16 PM

    Ryan Griffith's Avatar

    I know, right. So unconventional, but it works!

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  7. 7 Posted by espanae on 24 Apr, 2015 04:03 PM

    espanae's Avatar

    Thanks for the tips, guys. I reviewed the knowledge base and see that the [system-asset] tags are needed because Google's <meta content=".."/> tag isn't one of the recognized attributes tracked automatically.

    But I noticed Velocity is omitted from the list of assets that support "System-asset" and wanted to point that out.
    system-asset

  8. 8 Posted by Ryan Griffith on 24 Apr, 2015 04:10 PM

    Ryan Griffith's Avatar

    Thank you for notifying us of the incorrect information, Erik. I went ahead and updated the content to simply Formats so it includes both types.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  9. Ryan Griffith closed this discussion on 24 Apr, 2015 04:10 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? 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

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM