We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49983
    • 20 Posts
    Hi there,

    I am a newbie trying to learn some basic modx/development. I am in UX and love it as a CMS (creating structured content with TVs), but want to try and learn how to do more on my own and help take small tasks away from the developers.

    We are working on a site that allows users to create their own pages and upload photos to appear in their own hero slider. I have setup a JS slider to rotate through max 10 photos that I've setup as Template Variables.

    What I'm looking for help is to hide any photo TVs where an image wasn't uploaded. For example, if a user only uploaded 8 photos and not 10, how to hide the 9th and 10th. Right now TV photo 9 and TV photo 10 show as a grey background colour.

    This is what the code looks like in the template.

    <div class="item">[[*photo_1]]</div>
    <div class="item">[[*photo_2]]</div>
    <div class="item">[[*photo_3]]</div>
    <div class="item">[[*photo_4]]</div>
    <div class="item">[[*photo_5]]</div>
    <div class="item">[[*photo_6]]</div>
    <div class="item">[[*photo_7]]</div>
    <div class="item">[[*photo_8]]</div>
    <div class="item">[[*photo_9]]</div>
    <div class="item">[[*photo_10]]</div>

    Thanks,

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 22840
      • 1,572 Posts
      You might be better using MIGX fir this but if not you can use output modifiers but that may have an affect on speed

      [[*photo_1:notempty=`<div class="item">[[*photo_1]]</div>`]]
      • discuss.answer
        • 49983
        • 20 Posts
        Quote from: paulp at Mar 06, 2015, 10:14 AM
        You might be better using MIGX fir this but if not you can use output modifiers but that may have an affect on speed

        [[*photo_1:notempty=`<div class="item">[[*photo_1]]</div>`]]

        Hi Paulp,

        Wow, thanks so much that did the trick! I'm looking at MIGX now. It says that it'll aggregate multiple TVs into one. So, does this mean I would only need to make one call in the template and that is the advantage?

        Thanks again,
          • 5160
          • 118 Posts
          Another option, although this is more so you are aware of it than a recommendation in this situation, is the Asset Manager extra.

          It adds a new tab to resources and allows images to be uploaded, grouped and each can have a description. And you can specify the order to arrange them.

          It comes with a snippet to output them.
            • 49983
            • 20 Posts
            Thanks Chris! I'll take a look at that too!