How to display only the <system-page> node for the current page?

Eric's Avatar

Eric

21 Aug, 2014 08:02 PM

I have three pages named page1, page2, and page2.

I also have a long index block full of pages that is structured like this:

<system-index-block>
   <system-page id="1">
        <name>exhibit1</name>
        <title>Title</title>
        <path>/exhibitions/exhibition-items/exhibit1</path>
        <content>Some content</content> 
    </system-page>
   <system-page id="2">
        <name>exhibit2</name>
        <title>Title</title>
      <path>/exhibitions/exhibition-items/exhibit2</path>
        <content>Some content</content> 
    </system-page>
   <system-page id="3">
        <name>exhibit3</name>
        <title>Title</title>
        <content>Some content</content> 
       <path>/exhibitions/exhibition-items/exhibit1</path>
    </system-page>
</system-index block>

I am trying to print only the information inside <system-page id="3"></system-page> onto a page. However, I don't want to hardcode the system-page id. I'd like to write a format that will work for ANY system-page id (I'd like to write one format that would only print page2's data when I'm on page2, or only page1's data when I'm on page1.) How do I go about doing this?

Additional info: - Users will get to the page that ONLY contains information from a single specific <system-page> node by clicking a link set to the value of <path> (for example,) <a href="$system-page.getChild('path').value">Link</a>). Is that useful at all?

  1. 1 Posted by Eric on 21 Aug, 2014 08:04 PM

    Eric's Avatar

    I mean, I have three pages named exhibit1, exhibit2, exhibit3.

    The page names are the name as <system-page><name></name></system-page>

    I'm sorry for that mistake, I can't see where to edit my original question.

  2. 2 Posted by Ryan Griffith on 22 Aug, 2014 01:37 PM

    Ryan Griffith's Avatar

    Hi Eric,

    Displaying the content for the current page can be done a in a few ways.

    If you would like to use your current Index Block, you can filter the pages using the current attribute that is added to the <system-page> that is currently being viewed (ie the context page):

    #set ( $currentPage = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/system-page[@current]") )
    

    Alternatively, if all you want to do is output the content of the current page and nothing else, I would recommend using a calling page Index Block, which will only include the calling page's content and nothing else. This is generally more efficient than including a large Index Block. If you go this route, your Velocity would differ slightly:

    #set ( $currentPage = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page[@current]") )
    

    Also, I wanted to note that if you are running Cascade Server 7.10.1 or newer, Velocity Formats have access to a global $currentPage variable, which will be the calling page object. Slightly different than obtaining the page using the XPath Tool, but could help simplify things a bit. To view the properties of the $currentPage variable, you can use the following:

    $_PropertyTool.outputProperties($currentPage)
    

    Please let me know if you have any questions.

    Thanks!

  3. 3 Posted by Eric on 25 Aug, 2014 07:37 PM

    Eric's Avatar

    Thank you very much, I've used this information to successfully complete my task!

  4. 4 Posted by Ryan Griffith on 25 Aug, 2014 07:56 PM

    Ryan Griffith's Avatar

    Not a problem at all, Eric, thank you for following up. I am glad to hear I was able to point you in the right direction.

    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!

  5. Ryan Griffith closed this discussion on 25 Aug, 2014 07:56 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