We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34108
    • 66 Posts
    Hi guys smiley I'm wondering if anyone knows how to wrap a MIGX call in an IF statement to hide it if it's empty?

    For example I have this in my template:

    <h2>Images</h2>      
    [[$render-linked-gallery]]  
    


    And I'd like for the contents of [[$render-linked-gallery]] not to display at all if the client doesn't put any information into the related MIGX TV.

    Any ideas? A big thanks in advance!

    Harmony
      • 4172
      • 5,888 Posts
      try
      [[!getImageList? 
      &............
      &...........
      &toPlaceholder=`myMigxPh`
      ]]
      
      [[+myMigxPh:isnot=``:then=`
      <h2>Images</h2>
      [[+myMigxPh]]
      `:else=``]]
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 34108
        • 66 Posts
        Thanks Bruno smiley Fixed. Below is the code we used if it helps anyone. I put this in the chunk which formats the output (single-gallery-item) and called "render-linked-gallery" from my template.

        [[*show-linked-galleries:ne=``:then=`
          <h2>Images</h2>
          [[getImageList?
            &tvname=`show-linked-galleries`
            &tpl=`single-gallery-item`
          ]]
        `]]
        • Thanks for that Harmony, just want I needed for outputing several MIGX calls on one page for various tables, some of which were empty.

          Thanks for sharing smiley
            Helen Warner
            Number one pixel!
            Proud to be linked with MODX at Crimson Pixel
            • 30912
            • 463 Posts
            You can also use the If snippet as well.

            [[If? &subject=`[[*MIGxTV]]` &operator=`isempty` &then=`` &else=`<h2>Images</h2>
              [[getImageList?
                &tvname=`show-linked-galleries`
                &tpl=`single-gallery-item`
              ]]`]]
            
              • 12410
              • 353 Posts
              Hmmmm strange ... These solutions seem to have stopped working in MODX Revolution 2.2.12-pl (traditional). Result shows the else content regardless

               [[If? &subject=`[[*docs]]` &operator=`isempty` &then=`` &else=`<h2>Documents</h2>
                [[getImageList?
                  &tvname=`docs`
                  &tpl=`docs`
                ]]`]]


              I have IF installed and docs is a migx TV and chunk.
                • 4172
                • 5,888 Posts
                The MIGX - TV does return an empty json - string in some situations '[]'

                Use the toPlaceholder - property and check the result for empty, like that:

                [[getImageList?
                &toPlaceholder=`migx_output`
                &otherproperties ..........
                ]]
                
                [[+migx_output:!empty=`show this:[[+migx_output]]`]]

                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 12410
                  • 353 Posts
                  Thanks this works uncached

                  [[!getImageList? &tvname=`docs` &tpl=`docs` &toPlaceholder=`migx_output`]]
                  
                  [[+migx_output:!empty=`show this:[[+migx_output]]`]]
                    • 43284
                    • 7 Posts
                    Thank you, works like charm.
                      • 36446
                      • 184 Posts
                      Hi! Why isn't it possible to set a default Value in the Migx Template that is used in case there are no migx elements defined in the page?

                      I'm using migx right now for a slideshow and do not want to add different slides on all pages. I just wanted to use the default value property of my tv but unfortunately this is not working.
                      Or am i doing somthing wrong?
                        https://www.beautyislife-shop.de - premium make-up!
                        https://www.topsterne.de - sell it here!
                        ---------------------------------------------------------