Multiple text field options on a staff page

matthew.wren's Avatar

matthew.wren

03 Mar, 2016 04:53 PM

Hello,

I'm working on updating our academics staff pages... Our current design uses a two column table to create the page so I decided to recreate the page in velocity using bootstrap grid system so it's responsive. Each Faculty staff member's Data Definitions fields contains quite a bit of information but only three or so are giving me grief.

If you look at the screenshot attached, you'll see Internal Webpage, Internal Document, and External Website (with the multiple options).

For some reason I can not figure out how to get the multiple website to display. And with the two internal options, I have set to just hyperlink to the link with the title Internal Webpage or Internal Document but when these fields are blank, the links still appear and I can't figure it out.

I'll attach the XML and Velocity code here:

Velocity:

#set( $title = $_XPathTool.selectSingleNode( $contentRoot, 'page-title' ).value )
#set( $main = $_XPathTool.selectSingleNode( $contentRoot, 'paragraph' ))
<h1>$title</h1>
#if($main != "")
$_SerializerTool.serialize($main, true)
#else
$_SerializerTool.serialize($main, false)
#end
#set( $faculty = $_XPathTool.selectNodes( $contentRoot, 'faculty' ) )
<div class="container">
#foreach($f in $faculty)
    #set( $columns = $_XPathTool.selectSingleNode( $contentRoot, 'columns' ).value)
    #if($columns == "One")
        <div class="twelve columns color">    
    #else
        <div class="six columns double">
    #end
        #set($image = $f.getChild("photo").getChild("link").value)
        #set($path = $f.getChild("photo").getChild("path").value)
        #set($style = "float:right; padding: 0 7px 0 0; max-width: 100px")
        #set($margin = "margin: 0;")
        #set($alt = $f.getChild("photo").getChild("name").value)
    #if ($path != "/")
    ##     <img style="$style;" src="http://www.scranton.edu/alumni/journal/issues/2015/fall/commons/images/oncommons/commons3/seal.jpg"/>    
    ## #else
        <img style="$style;" src="$image" alt="$alt" />
    #end
    <div>
        <h2 style="$margin">$f.getChild( 'name' ).value</h2>
        <h3 style="$margin">$f.getChild( 'title' ).value</h3>
        #if ($f.getChild( 'dept' ).value != "")
        <h5 style="$margin">$f.getChild( 'dept' ).value</h5>
        #end
        #if ($f.getChild( 'email' ).value != "")
        <h5 style="$margin"><a href="mailto:$f.getChild( 'email' ).value">$f.getChild( 'email' ).value</a></h5>
        #end
        #if ($f.getChild( 'office' ).value != "")
            <h5 style="$margin">$f.getChild( 'office' ).value</h5>    
        #end
        #if ($f.getChild( 'phone' ).value != "")
            <h5 style="$margin">$f.getChild( 'phone' ).value</h5>
        #end
        
        
        
        
        #if ( $f.getChild( 'intpage' ).getChild('link') != "")
            <p style="$margin"><a href="$_EscapeTool.xml($f.getChild( 'intpage' ).getChild('link').value)">Internal Page</a></p>
        #end
    
        #if ( $f.getChild( 'intdoc' ).getChild('link') != "")
            <p style="$margin"><a href="$_EscapeTool.xml($f.getChild( 'intdoc' ).getChild('link').value)">Internal Document</a></p>
        #end
        
        
        #if ($f.getChild( 'interests' ).value != "" )
        <p style="$margin">$_EscapeTool.xml($f.getChild( 'interests' ).value)</p>
        #end
        #if ($f.getChild( 'addinfo' ).value != "")
        <p style="$margin">$_EscapeTool.xml($f.getChild( 'addinfo' ).value)</p>
        #end
        
        ## Multiple Website
        #set ( $website = $f.getChild( 'website' ))
        #if ( $website.size() > 0 )
            #foreach ($w in $website)
               <a href="$_EscapeTool.xml($w.value)">Website</a>
            #end
        #end
        
        
        
        
    </div>
    </div>
#end
</div>
<br/>
#set( $staff = $_XPathTool.selectNodes( $contentRoot, 'staff' ) )
<div class="container" style="margin: 4% 0 0 0;">
#foreach($s in $staff)
    #set( $columns = $_XPathTool.selectSingleNode( $contentRoot, 'columns' ).value)
    #if($columns == "One")
        <div class="twelve columns staff">    
    #else
        <div class="six columns double">
    #end
        #set($image = $s.getChild("photo").getChild("link").value)
        #set($path = $s.getChild("photo").getChild("path").value)
        #set($style = "float:left; padding: 0 7px 0 0; max-width: 100px")
        #set($margin = "margin: 0;")
        #set($alt = $s.getChild("photo").getChild("name").value)
    #if ($path == "/")
        <img style="$style;" src="http://www.scranton.edu/alumni/journal/issues/2015/fall/commons/images/oncommons/commons3/seal.jpg"/>    
    #else
        <img style="$style;" src="$image" alt="$alt" />
    #end
    <div>
        <h2 style="$margin">$s.getChild( 'name' ).value</h2>
        <h3 style="$margin">$s.getChild( 'title' ).value</h3>
        <h5 style="$margin"><a href="mailto:$s.getChild( 'email' ).value">$s.getChild( 'email' ).value</a></h5>
        <h5 style="$margin">$s.getChild( 'dept' ).value</h5>
        <h5 style="$margin">$s.getChild( 'office' ).value</h5>
        <h5 style="$margin">$s.getChild( 'phone' ).value</h5>
    </div>
    </div>
#end

</div>
  1. 1 Posted by Wing Ming Chan on 03 Mar, 2016 05:28 PM

    Wing Ming Chan's Avatar

    Hi,

    For intpage and intdoc, you need to check if the link is NULL:

    #if ( !$_PropertyTool.isNull( $f.getChild( 'intpage' ).getChild('link') ) )
    
    For multiple website, use getChildren( 'website' ) instead of getChild.

    Wing

  2. 2 Posted by matthew.wren on 03 Mar, 2016 06:49 PM

    matthew.wren's Avatar

    Thanks Wing, that all worked!

  3. Ryan Griffith closed this discussion on 03 Mar, 2016 08:41 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