We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20413
    • 2,877 Posts
    tvimageplus is awesome. It delievers all this from my Image TV [[*image01]]
         $xZ=1;
            if ($xZ==1) {    
                $chunkParams = array(
                    //mrhaw
                    'org' => $url2, 
                    'url' => $url,
                    'alt' => $data->altTag,
                    'link' => $data->linkField,
                    'width' => $data->targetWidth,
                    'height' => $data->targetHeight
                );
                //mrhaw
                //return $this->modx->getChunk($opts['outputChunk'], $chunkParams);
                return $this->modx->getChunk('imagePlus', $chunkParams);
            } else {
                // Otherwise return raw url
                return $url;
            }
    
        }
    


    Prossessing the TV will output those settings to placeholders in the tpl chunk "imagePlus".
        <li>
         <a href="[[+url]]" title="[[+alt]]">
          <img src="[[+org]]" alt="[[+alt]]">
         </a>
         <h4>[[+alt]]</h4>
        </li>
    


    These values goes missing when NOT processing the TV.

    But when listing my [[*image01]] using any snippet, I want the +url placeholder to point to the
    resource. I can't do conditional logic and use [[+id]] in the imagePlus chunk.
    // I even tried use methods like this: & #91;& #91;& #43;& #105;& #100;& #93;& #93;

    So I'm back at the imageplus code
    and wonder what code I could use to figure out it the TV is being called on
    the resource holding the value or not.

    if (main resource)
    return $this->modx->getChunk('imagePlus', $chunkParams);
    else
    return $this->modx->getChunk('imagePlusEXT', $chunkParams);


    Any ideas welcome! smiley

    This question has been answered by mrhaw. See the first response.

    [ed. note: mrhaw last edited this post 8 years, 11 months ago.]
      @hawproductions | http://mrhaw.com/

      Infograph: MODX Advanced Install in 7 steps:
      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
    • discuss.answer
      • 20413
      • 2,877 Posts
      Not an ideal solution, but accomplish what I need:

      imagePlusURL
      <?php
      $output = preg_replace('!href="([^"]+)"!','href="[[~[[+id]]]]"', $tv);
      return $output;
      


      Then using pdotools fastfield in a getReource tpl:
      [[imagePlusURL?tv=`[[#[[+id]].image01]]`]]
      
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower