Trying to get images and links to show... won't render

msyed1984's Avatar

msyed1984

15 Apr, 2014 10:54 PM

I'm trying to get this to print and it won't let show anything? What's wrong with the code?


#set ($griditems= $_XPathTool.selectNodes($contentRoot, '//gridpopup/griditem'))
#foreach ($gitem in $griditems)
#if ($gitem)
#set ($gimage = $gitem.getChild("gridimage").value)
#set ($glink = $gitem.getChild("griditemlink").value)
#set ($gname = $gitem.getChild("griditemname").value)
<div class="grid-item">
<a class="imglink" href="$glink"><img src="$gimage" alt="$gname"></a>
</div>
#else
<p>&nbsp;</p>
#end
#end
  1. 1 Posted by Ryan Griffith on 16 Apr, 2014 11:46 AM

    Ryan Griffith's Avatar

    Hi,

    I have a few questions to see if we can narrow things down a bit:

    • What output are you seeing currently?
    • Do you have a calling page Index Block applied to the region this Format is applied to?

    When you have a moment, also provide the sample XML generated using the Preview Options when editing the Format. Specifically, we'll want to include your page as context so the XML contains the gridpopup nodes.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by msyed1984 on 16 Apr, 2014 02:19 PM

    msyed1984's Avatar

    I do have a calling page. Attached is what it renders out.

    Here is the generated XML:

    
    <root><system-data-structure><header-image><content/><path>/_assets/images/prospective-header.png</path><link>site://GradDiv/_assets/images/prospective-header.png</link><site>GradDiv</site><name>prospective-header.png</name><display-name>prospective-header.png</display-name><summary>The UC Irvine Graduate Division mission is to serve as a catalyst for a world-class graduate educational experience, to foster oversight and communication of institutional academic policies, and to provide resources and essential services to promote the diversity and success of the next generation of leaders.</summary></header-image><quote-top>Something catchy here fdsafdsafdsa</quote-top><content>fdasfdsafdsafdasfdsafdsafdasfdsafdsafdasfdsafdsafdasfdsafdsafdasfdsafdsa</content><gridpopup><griditem><griditemlink><content/><path>/news-and-events/alumni-spotlights/caganberker </path><dynamic-metadata><name>in-side-menu</name><value>Yes</value></dynamic-metadata><link>site://GradDiv/news-and-events/alumni-spotlights/caganberker </link><site>GradDiv</site><name>caganberker </name><display-name>Cagan Berker </display-name><title>Engineering Alumnus Cagan Berker’s Poster Wins First Place</title><summary>Engineering Alumnus Cagan Berker’s Poster Wins First Place </summary><start-date>Dec 11, 2013 4:00 PM</start-date></griditemlink><gridimage><content/><path>/_assets/images/someguy.jpg</path><link>site://GradDiv/_assets/images/someguy.jpg</link><site>GradDiv</site><name>someguy.jpg</name></gridimage><griditemname>An image of a person</griditemname></griditem></gridpopup><resources><resource><header/><copy/></resource></resources></system-data-structure></root>
    

    And here is the xml preview of the base asset:

    
    <root><system-data-structure><header-image><path>/</path></header-image><quote-top>Something catchy here</quote-top><content/><gridpopup><griditem><griditemlink><path>/</path></griditemlink><gridimage><path>/</path></gridimage><griditemname>An image of a person</griditemname></griditem></gridpopup><resources><resource><header/><copy/></resource></resources></system-data-structure></root>
    
  3. 3 Posted by Ryan Griffith on 17 Apr, 2014 01:57 PM

    Ryan Griffith's Avatar

    Hi,

    It looks like you are close, but for the gridimage and griditemlink elements you are attempting to convert an element to a value. Instead, you want to grab the value of the link element.

    When you have a moment, try the following and let me know how it works out for you:

    #set ($griditems= $_XPathTool.selectNodes($contentRoot, '//gridpopup/griditem'))
    #foreach ($gitem in $griditems)
        #if ($gitem)
            #set ($gimage = $gitem.getChild("gridimage").getChild("link").value)
            #set ($glink = $gitem.getChild("griditemlink").getChild("link").value)
            #set ($gname = $gitem.getChild("griditemname").value)
            <div class="grid-item">
                <a class="imglink" href="$glink"><img src="$gimage" alt="$gname"/></a>
            </div>
        #else
            <p>&nbsp;</p>
        #end
    #end
    

    Please let me know if you have any questions.

    Thanks!

  4. Ryan Griffith closed this discussion on 29 Apr, 2014 04:15 PM.

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

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