ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to display a single banner image or multiple slideshow images?

May 06, 2012 2:17pm

Subscribe [2]
  • #1 / May 06, 2012 2:17pm

    stephencapp

    12 posts

    Hi there - I’m sure this is a pretty straight forward task but I’m not sure how to get it done properly.

    I have a series of templates that allow users to add either a single banner image or a slideshow at the top of each page.

    Each template has two P&T Assets fields. The first only allows a single image to be entered and the second allows multiple images.

    The issue I have is shutting off one or the other. If a single image is used there is no trace of the slideshow on the page. However, if the slideshow is used, there is a broken image icon where the single image would go on the page. It only appears in Safari that I know of. If I view the source I see “” above the slideshow.

    Here’s the code I’m using in the template - am I using the if statement correctly? Is this the best approach?

    {if single_banner_image_country == single_banner_image_country}{single_banner_image_country}
    <div id=“featured-image” class=“theme-default”>
    <div id=“slider” class=“nivoSlider”>
    {rotating_banner_images_country}
      {url}
    {/rotating_banner_images_country}
    </div>
    </div>
    {/if}

    Here’s a URL of the page in development: http://bigplanetadventuretravel.com/country/eastern-africa

    Thanks for your time!

  • #2 / May 07, 2012 12:03pm

    e-man

    1816 posts

    Should probably be something more like:

    {if single_banner_image_country}
    {single_banner_image_country}
    {if}
    
    {if rotating_banner_images_country}
    <div id="featured-image” class="theme-default">
    <div id="slider” class="nivoSlider">
    {rotating_banner_images_country}
      {url}
    {/rotating_banner_images_country}
    </div>
    </div>
    {/if}

    Not even sure you need separate fields for this, you could check if your asset field holds 1 image or more than 1 and adjust the code accordingly.

  • #3 / May 07, 2012 3:12pm

    stephencapp

    12 posts

    Thanks for that e-man! That looks more like what I need.

    Ideally, I could use a single field but the Nivo JQuery slider I’m using still shows the controls whether there’s one image or five which looks kind of wonky. So I’ve got two fields for now.

    Maybe I should revisit the slider and find something that only shows controls when more than one image has been added. It seems that that would be a cleaner solution.

  • #4 / May 07, 2012 3:31pm

    e-man

    1816 posts

    If you plan on using lots of conditionals in your templates (and at some point you will or will have to), if you haven’t already, be sure to check out Switchee and IfElse by M. Croxton:
    http://devot-ee.com/search/results/search&keywords=croxton&channel=addons&addon_version_support=ee2
    They can really speed up your templates and take some of the overhead out of using advancec conditionals (if ... elseif ... if). More info on parse order: http://gotolow.com/parse-order

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases