Strange data definition issue on page

matthew.wren's Avatar

matthew.wren

12 Mar, 2014 08:02 PM

There's a strange thing going on with this page where we add 3 open/close tabs on the page but a fourth one appears that's blank. In Casade, there are only 3 such items but there's always one extra one to appear. I have tried adding another item but there's still and empty one appearing at the end.

Is there something I can edit to prevent this from happening? I've tried editing the amount of boxes that appear to 3 and that didn't work. Not sure why this is happening.

  1. 1 Posted by Ryan Griffith on 12 Mar, 2014 08:33 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    This sounds like possibly an issue with the Format used to generate those sections. Perhaps it is accounting for an empty group or maybe just generating one too many sections. I'd be happy to try and take a look at the Format if you would like to attach it with this discussion.

    Thanks!

  2. 2 Posted by matthew.wren on 13 Mar, 2014 01:09 PM

    matthew.wren's Avatar
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
        <xsl:output indent="yes" method="html"/>
    
    <xsl:template match="system-index-block">
    
        <xsl:if test="(//system-page[@current='true']/display-name) and (//system-page[@current='true']/display-name !='')">
    <h1><xsl:value-of select="//system-page[@current='true']/display-name"/></h1>
    </xsl:if>
    
    <xsl:apply-templates select="//system-page[@current='true']/system-data-structure"/>
    </xsl:template>
    
    
        <xsl:template match="system-data-structure">
    
    
            <xsl:copy-of select="main-content/content/node()"/>
            <!-- PRIMARY BUCKETS -->
            <xsl:if test="primary-buckets/display = 'Yes' and primary-buckets/bucket/title !=''">
                <xsl:apply-templates select="primary-buckets"/>
            </xsl:if>       
            <!-- SECONDARY BUCKETS -->
            <xsl:if test="secondary-buckets/display = 'Yes' and secondary-buckets/bucket/title !=''">
                <xsl:apply-templates select="secondary-buckets"/>
            </xsl:if>
    
            
    
            <!--Accordion-->
            <xsl:if test="(supplemental-content/accordion/display = 'Yes' and supplemental-content/accordion/item/title !='') or (supplemental-content/benefits/display = 'Yes' and supplemental-content/benefits/item/title !='')">
                    <xsl:apply-templates select="supplemental-content/accordion"/>
            </xsl:if>
    
            <!--Highlight Box-->
            <xsl:if test="supplemental-content/highlightbox/display = 'Yes' and supplemental-content/highlightbox/title !=''">
                    <xsl:apply-templates select="supplemental-content/highlightbox"/>
            </xsl:if>
            
            <!--numbers-->
            <xsl:if test="numbers/display = 'Yes'">
                <xsl:apply-templates select="numbers"/>
            </xsl:if>
    
    
    
        </xsl:template>
    
        <xsl:template match="primary-buckets">
            <div class="row">
                <xsl:for-each select="bucket">
                    <div class="columns featured-program two-cols">
                        <h2>
                            <xsl:value-of select="title"/>
                        </h2>
                        <img alt="{title}" src="{img/path}"/>
                        <p>
                            <xsl:value-of select="content"/>
                        </p>
                        <xsl:for-each select="links/link">
                        <xsl:call-template name="link"/>
                        </xsl:for-each>
    <xsl:apply-templates select="dropdown"/>
    
                    </div>
                </xsl:for-each>
            </div>
        </xsl:template>
    
        <xsl:template match="secondary-buckets">
            <div class="row featured-programs three-cols">
                <xsl:for-each select="bucket">
                <div class="columns featured-program three-cols">
                    <img alt="{title}" src="{img/path}"/>
                    <h3><xsl:value-of select="title"/></h3>
                    <p><xsl:value-of select="content"/></p>
                    <xsl:call-template name="link"/>
                </div>
                </xsl:for-each>
            </div>
        </xsl:template>
    
     <xsl:template match="accordion">
            <div class="vertical-collapse">
                <ul>
                <!--Benifits Box-->
            <xsl:if test="//system-page[@current='true']/system-data-structure/supplemental-content/benefits/display = 'Yes' and //system-page[@current='true']/system-data-structure/supplemental-content/benefits/item/title !=''">
                    <xsl:apply-templates select="//system-page[@current='true']/system-data-structure/supplemental-content/benefits"/>
            </xsl:if>
                <xsl:for-each select="item">
                    <li>
                        <h2><xsl:value-of select="title"/><span>plus or minus</span></h2>
                        <section>
                            <div class="vertical-collapse-content">
                                <xsl:copy-of select="content/node()"/>
                            </div>
                        </section>
                    </li>
                </xsl:for-each>
                </ul>
            </div>
        </xsl:template>
    
    <xsl:template match="benefits">        
                <li>
                <xsl:if test="position() = 1"><xsl:attribute name="class">open</xsl:attribute></xsl:if>
                <xsl:variable name="benefitstitle">
                <xsl:choose>
                <xsl:when test="title!= ''"><xsl:value-of select="title"/></xsl:when>
                <xsl:otherwise>Royal Benefits</xsl:otherwise>
                </xsl:choose>
                </xsl:variable>
          <h2><xsl:value-of select="$benefitstitle"/><span>plus or minus</span></h2>
          <section><div class="vertical-collapse-content"> <div class="round-numbers">
    <xsl:apply-templates mode="benefits" select="item"/>
          </div></div>
                       
                       </section>
                       </li>            
        </xsl:template>
    
    
        <xsl:template match="item" mode="benefits">
                <div class="round-number"><span><xsl:value-of select="position()"/></span></div>
                <div class="round-number-content">
                  <h3><xsl:value-of select="title"/></h3>
                  <xsl:copy-of select="content/node()"/>
                </div>
        </xsl:template>
    
        <xsl:template name="link">
            <xsl:choose>
                <xsl:when test="(link-page/page/path != '/') or (link-external/url != '' and link-external/url != 'http://') or (link-file/file/path != '/')">
                    <a>
                        <xsl:choose>
                            <xsl:when test="link-page/page/path != '/'">
                                <xsl:attribute name="href">[system-asset]<xsl:value-of select="link-page/page/link"/>[/system-asset]</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="link-file/file/path != '/'">
                                <xsl:attribute name="href">[system-asset]<xsl:value-of select="link-file/file/path"/>[/system-asset]</xsl:attribute>
                                <xsl:attribute name="target">_blank</xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="link-text"/>- This link will open in a new window.</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="link-external/url != '' and link-external/url != 'http://'">
                                <xsl:attribute name="href">
                                    <xsl:value-of select="link-external/url"/>
                                </xsl:attribute>
                                <xsl:if test="link-external/target = 'New Window'">
                                    <xsl:attribute name="target">_blank</xsl:attribute>
                                    <xsl:attribute name="title">
                                        <xsl:value-of select="link-text"/>- This link will open in a new window.</xsl:attribute>
                                </xsl:if>
                            </xsl:when>
                        </xsl:choose>
                        <xsl:value-of select="link-text"/> »</a>
                </xsl:when>
                <xsl:otherwise/>
            </xsl:choose>
        </xsl:template>
    
       <xsl:template match="dropdown">
            <xsl:if test="(display = 'Yes') and (item/link-text != '')">
                <select class="treat-as-links">
                <option>Please Select</option>
                    <xsl:for-each select="item">
                        <option>
                        <xsl:choose>
                            <xsl:when test="page/path != '/'">
                                <xsl:attribute name="value">[system-asset]<xsl:value-of select="page/link"/>[/system-asset]</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="external != '' and external != 'http://'">
                                <xsl:attribute name="value"><xsl:value-of select="external"/></xsl:attribute>
                            </xsl:when>
                            <xsl:otherwise/>
                        </xsl:choose>
                        <xsl:value-of select="link-text"/></option>
                    </xsl:for-each>
                </select>
            </xsl:if>
        </xsl:template>
    
    
        <xsl:template match="highlightbox">
            <div class="row athletics-website">
              <div class="six columns site-image">
                <img alt="{title}" src="{img/path}"/>
              </div>
              <div class="six columns site-info-caption">
                <h2><xsl:value-of select="title"/></h2>
                <xsl:copy-of select="content/node()"/>
    
              </div>
            </div>  
        </xsl:template>
    
    
        <xsl:template match="numbers">
        <div class="row by-the-numbers">
      <h2>By The Numbers</h2>
      <div class="slider-container">
       <ul class="slider-tabs">
       <xsl:for-each select="slide[position() mod 2 = 1]">
            <li><a href="#slide-{position()}"></a></li>
    
       </xsl:for-each>
        </ul>
            <div class="slider">
                <xsl:apply-templates select="slide"/>
            </div>
            </div>
            
      <span class="slide-cntrl prev" data-prev-slide=""></span>
      <span class="slide-cntrl next" data-next-slide="1"></span>
      </div>
        </xsl:template>
    
    <xsl:template match="slide">
    <xsl:if test="position() mod 2 = 1">
        <xsl:comment>#START-CODE<![CDATA[<div id="slide-]]>#END-CODE</xsl:comment><xsl:value-of select="ceiling(position() div 2)"/><xsl:comment>#START-CODE<![CDATA[" class="row slide">]]>#END-CODE</xsl:comment>
        </xsl:if>
    <div class="six columns slide-inner">
                  <h3>
                    <span class="left-col stacked {number-color}"><xsl:value-of select="number-text"/></span>
                    <span class="right-col {content-color}"><xsl:value-of select="content-text"/>
                    
                     <xsl:if test="(link-page/page/path != '/') or (link-external/url != '' and link-external/url != 'http://') or (link-file/file/path != '/')">
                    <a class="inline">
                        <xsl:choose>
                            <xsl:when test="link-page/page/path != '/'">
                                <xsl:attribute name="href">[system-asset]<xsl:value-of select="link-page/page/link"/>[/system-asset]</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="link-file/file/path != '/'">
                                <xsl:attribute name="href">[system-asset]<xsl:value-of select="link-file/file/link"/>[/system-asset]</xsl:attribute>
                                <xsl:attribute name="target">_blank</xsl:attribute>
                                <xsl:attribute name="title">
                                    <xsl:value-of select="link-text"/>- This link will open in a new window.</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="link-external/url != '' and link-external/url != 'http://'">
                                <xsl:attribute name="href">
                                    <xsl:value-of select="link-external/url"/>
                                </xsl:attribute>
                                <xsl:if test="link-external/target = 'New Window'">
                                    <xsl:attribute name="target">_blank</xsl:attribute>
                                    <xsl:attribute name="title">
                                        <xsl:value-of select="link-text"/>- This link will open in a new window.</xsl:attribute>
                                </xsl:if>
                            </xsl:when>
                        </xsl:choose>
                        more</a>
                </xsl:if>
                    </span>
                  </h3>
                </div>
        <xsl:if test="position() mod 2 = 0 and position()!=last()">
        <xsl:comment>#START-CODE<![CDATA[</div>]]>#END-CODE</xsl:comment>
        </xsl:if>
        <xsl:if test="position()=last()">
        <xsl:comment>#START-CODE<![CDATA[</div>]]>#END-CODE</xsl:comment>
        </xsl:if>
    </xsl:template>
    
    
    </xsl:stylesheet>
    
  3. 3 Posted by Ryan Griffith on 13 Mar, 2014 03:37 PM

    Ryan Griffith's Avatar

    Thank you for providing the Format, Matthew.

    I would recommend simply checking for the existence of a title for the items when looping through them. This should avoid the extra accordion. When you have a moment, try adjusting the accordion template as follows and let me know how it works out:

     <xsl:template match="accordion">
            <div class="vertical-collapse">
                <ul>
                <!--Benifits Box-->
            <xsl:if test="//system-page[@current='true']/system-data-structure/supplemental-content/benefits/display = 'Yes' and //system-page[@current='true']/system-data-structure/supplemental-content/benefits/item/title !=''">
                    <xsl:apply-templates select="//system-page[@current='true']/system-data-structure/supplemental-content/benefits"/>
            </xsl:if>
                <xsl:for-each select="item[title != '']">
                    <li>
                        <h2><xsl:value-of select="title"/><span>plus or minus</span></h2>
                        <section>
                            <div class="vertical-collapse-content">
                                <xsl:copy-of select="content/node()"/>
                            </div>
                        </section>
                    </li>
                </xsl:for-each>
                </ul>
            </div>
        </xsl:template>
    

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by matthew.wren on 13 Mar, 2014 03:54 PM

    matthew.wren's Avatar

    Wonderful! That worked.

    So this snippet <xsl:for-each select="item[title != '']">, more specifically the [title != ''] portion of it checks if there's a title and if not it'll prevent another accordion from displaying? Just so I understand this correctly.

  5. 5 Posted by Ryan Griffith on 13 Mar, 2014 04:40 PM

    Ryan Griffith's Avatar

    Thank you for following up, Matthew.

    You are correct, the XPath will filter only items with a non-empty title field.

    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!

  6. Ryan Griffith closed this discussion on 13 Mar, 2014 04:40 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