We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42901 ☆ A M B ☆
    • 73 Posts
    <section role="banner">
    [[!getImageList? &tvname=`imageSelector`&tpl=`@CODE:
    <a class="preview" [[+video:notempty=`href="[[+video]]" rel="shadowbox;width=720;height=480;"`:else=`href="[[+image]]" rel="shadowbox[Img]"`]] title="[[+title]]"><img src="[[+image]]" alt="[[+alt]]"></a>`]]
    </section><!-- images -->
    


    These are the input fields:
    +image (selector)
    +alt
    +title
    +video

    Here is what I hope to accomplish. I'm using shadowbox to display images input using MIGX. By default, images are automatically given a shadowbox call. I got the image portion working as it should.

    HOWEVER...Now, I want to get a little fancy:
    If I input a video URL to the +video field, I would like the href="" to be populated with that link. If I don't fill out the +video part, I want it to fall back to the image. What I have above simply isn't working. (Or, problem lies between chair and computer?)

    This is typically what I'm trying to achieve:

    if +video = hascontent then <a href="[[+video]]" rel="shadowbox;width=720;height=480;" title="[[+title]]>
    else = <a href="[[+image]]" rel="shadowbox[Img]" title="[[+title]]>
    
      Woodlands Ad Agency
      Our blog should NOT be read by anyone....EVER http://woodlandsadagency.com/blog/
      ...Don't say we didn't warn you.
      • 3109 ☆ A M B ☆
      • 894 Posts
      Try this instead:

      
      <section role="banner">
      [[!getImageList? &tvname=`imageSelector`&tpl=`@CODE:
      [[+video:!empty=`<a class="preview" href="[[+video]]" rel="shadowbox;width=720;height=480;" title="[[+title]]"><img src="[[+image]]" alt="[[+alt]]"></a>`:else=`<a class="preview" href="[[+image]]" rel="shadowbox[Img]" title="[[+title]]"><img src="[[+image]]" alt="[[+alt]]"></a>`]]
      `]]
      </section><!-- images -->
      
      


      Or try putting the @Code portion in a chunk instead of inline.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 42901 ☆ A M B ☆
        • 73 Posts
        Hey Ben,

        Yeah, I tried your method as well - no dice but the chunk idea is definitely something I didn't think of so BIG THANKS!

        Would it work something like this?

        <section role="banner">
        [[!getImageList? &tvname=`imageSelector`&tpl=`someChunk`]]
        </section>
        


        Then $someChunk would be this?

        [[+video:!empty=`<a class="preview" href="[[+video]]" rel="shadowbox;width=720;height=480;" title="[[+title]]"><img src="[[+image]]" alt="[[+alt]]"></a>`:else=`<a class="preview" href="[[+image]]" rel="shadowbox[Img]" title="[[+title]]"><img src="[[+image]]" alt="[[+alt]]"></a>`]]
        


        (wow I'm a n00b!)
          Woodlands Ad Agency
          Our blog should NOT be read by anyone....EVER http://woodlandsadagency.com/blog/
          ...Don't say we didn't warn you.
          • 42901 ☆ A M B ☆
          • 73 Posts
          I'm sure there is a way to do this but for now, I'm taking the 'easy' way out. I simply created two separate TV's using MIGX - one for regular images, the second one for images that will display videos when selected.
          Both handled by their own separate chunks.

          It's a band-aid approach but it works. I just have to put videos at the bottom below images. (For now)

          That's what's nice about MODX - you can make it work even when you can't make it work.
            Woodlands Ad Agency
            Our blog should NOT be read by anyone....EVER http://woodlandsadagency.com/blog/
            ...Don't say we didn't warn you.