If empty, other regions fill void

Tim Corwin's Avatar

Tim Corwin

03 Jun, 2016 02:38 PM

Hi,

If a given content area of a page is empty, I want it to disappear and not turn into an empty blank space.

For instance, the FORMAT file for our Athlete page code is:

<div class="person-photo"><img alt="{$athlete-name}" height="271" src="{$athlete-photo}" width="221"/></div>
    <div class="person-summary">
      <h1 class="small-margin"><xsl:value-of select="athlete-name"/></h1>

      <dl class="chars cf">
        <dt>Number</dt>
        <dd><xsl:value-of select="athlete-number"/></dd>
        <dt>Year</dt>
        <dd><xsl:value-of select="athlete-year"/></dd>
        <dt>Position</dt>
        <dd><xsl:value-of select="athlete-position"/></dd>
        <dt>Height</dt>
        <dd><xsl:value-of select="athlete-height"/></dd>
        <dt>High school</dt>
        <dd><xsl:value-of select="athlete-high-school"/></dd>
        <dt>Hometown</dt>
        <dd><xsl:value-of select="athlete-home-town"/></dd>
      </dl>
    </div>

So, if there is no photo, I would like the other content to fill that photo gap.

Also, is this were you set that (FORMAT) or is that a Data Definition thing? Or even TEMPLATE thing?

Here's how one of these looks with a photo:

http://ridgewater.cloudapp.net/Athletics/womens-sports/volleyball/roster/hailey-leiding.asp

But we don't have a photo of everyone so it would be nice to have that empty space not be an empty space but filled with the Roster Info instead (to the right).

Thanks,

-Tim

Tim Corwin
Webmaster
[email blocked]<mailto:[email blocked]>
(320) 234-8574
[logo-200x55]

  1. 1 Posted by Ryan Griffith on 06 Jun, 2016 05:05 PM

    Ryan Griffith's Avatar

    Hi Tim,

    What you would want to do is surround the photo content with an <xsl:if> that checks to see if an image was chosen before attempting to output it. Here is an example to help get you started:

    <xsl:if test="$athlete-photo != '/'">
    <div class="person-photo"><img alt="{$athlete-name}" height="271" src="{$athlete-photo}" width="221"/></div> 
    </xsl:if>
    

    Note: I am assuming $athlete-photo is a variable you have saved as the path of your file chooser.

    Please let me know if you have any questions.

    Thanks!

  2. 2 Posted by Tim Corwin on 06 Jun, 2016 07:16 PM

    Tim Corwin's Avatar

    Tim Corwin
    Webmaster
    [email blocked]<mailto:[email blocked]>
    (320) 234-8574
    [logo-200x55]

    From: Ryan Griffith [mailto:[email blocked]]
    Sent: Monday, June 6, 2016 12:06 PM
    To: Tim Corwin <[email blocked]>
    Subject: Re: If empty, other regions fill void [XSLT Formats #6737]

    WOW. That worked GREAT!

    Can you use the same logic on the lines just below the ones I cited below (?)

    <h3>BIO / STATS</h3>

                <xsl:copy-of select="athlete-bio/node()"/>

            </div>

    So if the wysiwyg area (“athlete-bio/done()”) is blank, the BIO STATS won’t show up (as it does now)?

    -Tim

  3. 3 Posted by Ryan Griffith on 06 Jun, 2016 07:23 PM

    Ryan Griffith's Avatar

    Not a problem at all, Tim.

    You can use the same logic. Note; however, that testing for empty WYSIWYG content is slightly different. We have an article which outlines how to test for an empty WYSIWYG field to help get you started.

    Please let me know if you have any questions.

    Thanks!

  4. 4 Posted by Tim Corwin on 06 Jun, 2016 08:01 PM

    Tim Corwin's Avatar

    Tim Corwin
    Webmaster
    [email blocked]<mailto:[email blocked]>
    (320) 234-8574
    [logo-200x55]

    From: Ryan Griffith [mailto:[email blocked]]
    Sent: Monday, June 6, 2016 2:23 PM
    To: Tim Corwin <[email blocked]>
    Subject: Re: If empty, other regions fill void [XSLT Formats #6737]

    Hi,

    Yes, I’ve seen this “copy of” before BUT what I’m trying to get RID of is the “<h3> BIO/STATS</h3> part.

    We have the same problem with another FORMAT with an IMAGE GALLERY title that we want to disappear if there is no gallery.

    ?

  5. 5 Posted by Ryan Griffith on 06 Jun, 2016 08:27 PM

    Ryan Griffith's Avatar

    Correct, so what you would do is surround that content with a check that makes sure the "bio" field is not empty:

    <xsl:if test="athlete-bio/node()">
        <h3>BIO / STATS</h3>
        <xsl:copy-of select="athlete-bio/node()"/>
    </div>
    

    Please let me know if you have any questions.

    Thanks!

  6. 6 Posted by Tim Corwin on 06 Jun, 2016 09:27 PM

    Tim Corwin's Avatar

    Wow.

    That worked!

    Thank you so much!

    -Tim

    Tim Corwin
    Webmaster
    [email blocked]<mailto:[email blocked]>
    (320) 234-8574
    [logo-200x55]

  7. Support Staff 7 Posted by Tim on 06 Jun, 2016 09:28 PM

    Tim's Avatar

    Hey Tim,

    Glad Ryan was able to help out here. Have a good one!

  8. Tim closed this discussion on 06 Jun, 2016 09:28 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