Displaying system-page-title with Velocity

S. Croniser's Avatar

S. Croniser

09 Feb, 2015 04:06 PM

Hello!

I've been using XSLT, but recently came across an issue better solved with another language, so it made sense to learn Velocity. The problem is that we typically pull the page title for the DEFAULT using <xsl:value-of select="system-page-title"/>. I've not been able to figure out it's equivalent in Velocity. Is it just not possible when a index block is plugged into the DEFAULT section?

Here's the beginning of what we use in XSLT:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:include href="site://WCMS-Commons/format-date"/>
    <xsl:template match="system-data-structure">
    <xsl:param name="titleDate" select="''"/>
        <div id="content" role="main">
            <h2>
                <system-page-title/>
            </h2>

Here's what I've tried in Velocity (along with many others that I can't remember):

#set($title = $_XPathTool.selectNodes($contentRoot, '//calling-page')) ##doesn't work because there is no calling page for RSS blocks
#set($title = $_XPathTool.selectNodes($contentRoot, '//system-page-title'))
#set($title = $_XPathTool.selectSingleNode($contentRoot, '//page-title'))
#set($title = $_XPathTool.selectSingleNode($contentRoot, '//page/system-page-title'))

Any suggestions?

  1. 1 Posted by Ryan Griffith on 09 Feb, 2015 04:16 PM

    Ryan Griffith's Avatar

    Hi,

    If you are running Cascade Server 7.10.1 or newer, you can use the predefined $currentPage Velocity variable which will give you access to the calling page's information. For example:

    $currentPage.metadata.title
    

    Note: the $currentPage variable uses the Cascade API, which differs from the XML data you are accustomed to when working with Index Blocks and XSLT Formats or the Velocity XPath Tool. The API is also used by the Velocity Locator Tool.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by S. Croniser on 09 Feb, 2015 04:25 PM

    S. Croniser's Avatar

    Thanks for the fast reply. This solved my issue - I knew it had to be something simple!

  3. 3 Posted by Ryan Griffith on 09 Feb, 2015 04:29 PM

    Ryan Griffith's Avatar

    Not a problem at all, glad to hear you were able to use the $currentPage variable to meet your needs.

    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!

  4. Ryan Griffith closed this discussion on 09 Feb, 2015 04:29 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