We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6094
    • 60 Posts
    Maybe this isn’t possible, but I’m trying to execute PHx within a chunk. I have the following section of code within the chunk.

    <img src="[+portfolioImgSml001+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml001" />

    [+portfolioImg002:len:gt=`0`:then=`<img src="[+portfolioImgSml002+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml002"/>`+]

    [+portfolioImg003:len:gt=`0`:then=`<img src="[+portfolioImgSml003+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml003"/>`+]

    [+portfolioImg004:len:gt=`0`:then=`<img src="[+portfolioImgSml004+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml004"/>`+]


    The first image portfolioImgSml001 displays without issue of course. However, the second (portfolioImgSml002 does not display an image. I get the broken image, but the alt tag is working. The image is in the assets folder because it works effectively on another page. The 3rd and 4th images do not display as expected, but there are no images associated with these TVs.

    It seems like it recognizes that there is an image because it places it appropriately including the alt tag, but it’s just not displaying it. Is it even possible to do this? I’m really new to this so any help is greatly appreciated.
      • 3707
      • 241 Posts
      Try changing the +’s to a *’s so you are referencing variables rather than placeholders
      [*portfolioImg002:len:gt=`0`:then=`<img src="[*portfolioImgSml002*]" alt="[*pagetitle*]" width="75" height="75" class="latestImgFormatSml002"/>`*]
      [*portfolioImg003:len:gt=`0`:then=`<img src="[*portfolioImgSml003*]" alt="[*pagetitle*]" width="75" height="75" class="latestImgFormatSml003"/>`*]
      [*portfolioImg004:len:gt=`0`:then=`<img src="[*portfolioImgSml004*]" alt="[*pagetitle*]" width="75" height="75" class="latestImgFormatSml004"/>`*]
        • 6094
        • 60 Posts
        Thank you for your comment. Unfortunately, that didn’t seem to work. Now there is no display not even a broken image link.
        Anyone else care to weigh in?
          • 34017
          • 898 Posts
          [*portfolioImg004:ifnottempty=`<img src="[+portfolioImgSml002+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml002"/>`*]

          The phx:snippet ifnotempty is here:
          http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:ifnotempty

          it should work.
            Chuck the Trukk
            ProWebscape.com :: Nashville-WebDesign.com
            - - - - - - - -
            What are TV's? Here's some info below.
            http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
            http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
            • 3707
            • 241 Posts
            How are you calling the chunk, directly from a template or document, or via a snippet e.g. Ditto?
              • 6094
              • 60 Posts
              The chunk is being called via Ditto:

              [[Ditto? &parents`5` &display=`1` &orderBy=`createdon DESC` &tpl=`workPrimaryDisplay`]]
              


              and the chunk workPrimaryDisplay contains the following:
              <img src="[+portfolioImgSml001+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml001" />
              
              [+portfolioImg002:len:gt=`0`:then=`<img src="[+portfolioImgSml002+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml002"/>`+]
              
              [+portfolioImg003:len:gt=`0`:then=`<img src="[+portfolioImgSml003+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml003"/>`+]
              
              [+portfolioImg004:len:gt=`0`:then=`<img src="[+portfolioImgSml004+]" alt="[+pagetitle+]" width="75" height="75" class="latestImgFormatSml004"/>`+]
                • 3707
                • 241 Posts
                In that case you need a different method, my earlier method only works when calling a chunk directly.

                Ditto isn’t aware of TV’s by default so I believe you need to use the hiddenFields parameter to get Ditto to retrieve them.

                Try changing your Ditto call to:
                [[Ditto? &parents`5` &display=`1` &orderBy=`createdon DESC` &tpl=`workPrimaryDisplay` &hiddenFields=`portfolioImgSml002,portfolioImgSml003,portfolioImgSml004`]]
                  • 6094
                  • 60 Posts
                  That did the trick grin. Thanks so much for your help!
                    • 34017
                    • 898 Posts
                    I think the newer version of ditto doesnt need the hiddenfields option. I always forgot that and it’s a good reason to upgrade.
                      Chuck the Trukk
                      ProWebscape.com :: Nashville-WebDesign.com
                      - - - - - - - -
                      What are TV's? Here's some info below.
                      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008