We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15558
    • 108 Posts
    The following code is used in my AdvSearch result template to display an image among other tvs :

    [[GalleryItem?  &id=`[[getPicId? &imageTV=`[[+tvMainPic]]`]]` &toPlaceholders=`0` &tpl=`tplGalleryitem` ]]


    I have to call a &tpl instead of using placeholders, due to some caching issue.

    tplGalleryitem chunk is:
    <a href="[[+url:is=``:then=`[[+image]]`:else=`[[+url]]`]]">
    <img src="[[+image]]" alt="[[+name]]" />
    </a>
    


    ... and everything works fine, except that it outputs an error also and before all :

    Notice: Undefined variable: output in C:\my\path\core\cache\includes\elements\modsnippet\9.include.cache.php on line 133

    which is

    if (empty($tpl)) return '';
    $output .= $gallery->getChunk($tpl,$itemArray);
    return $output;
    }

    ( = line 128 here : https://github.com/splittingred/Gallery/blob/develop/core/components/gallery/elements/snippets/snippet.galleryitem.php )

    Can someone have a look at this please ? I can't fix this for myself...

    modx 2.2.7

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

    [ed. note: kehezen last edited this post 10 years, 11 months ago.]
      Sorry for that ⇧ , I'm no dev but I wanna try
      • 15558
      • 108 Posts
      I'm still struggling with that issue.

      This is my call
      [[GalleryItem? &id=`[[getPicId? &imageTV=`[[+tvMainPic]]`]]` &toPlaceholders=`1` &tpl=`tplGalleryitem` &imageWidth=`750` &imageHeight=`562` &imageZoomCrop=`0` ]]


      The Notice : Undefined variable appears when I set &toPlaceholders to 0, no matter if I add the &tpl property or not. The fact is that my tpl is called, and everything works fine... except that error that messes it all.

      Can someone please have a look at this ? [ed. note: kehezen last edited this post 10 years, 11 months ago.]
        Sorry for that ⇧ , I'm no dev but I wanna try
      • discuss.answer
        • 15558
        • 108 Posts
        okay I solved this by removing the dot in this line


        $output .= $gallery->getChunk($tpl,$itemArray);


        This is at the bottom of the GalleryItem snippet.

        I don't know if this is viable. I don't even know what .= means, nor what the dot implies.

        However, it seems to be ok. Feel free to tell me what kind of mess I might have done.
          Sorry for that ⇧ , I'm no dev but I wanna try
          • 36788
          • 75 Posts
          Here are some details on this "dot" operator: http://us2.php.net/manual/en/language.operators.string.php
          And many other helpful things))

          For this particular case you were absolutely right removing the dot.

          Though it is better to add the check before the line causing this kind of errors:
           if (!isset($output)){$output='';}
          $output .= $gallery->getChunk($tpl,$itemArray);
          [ed. note: sladdals last edited this post 10 years, 11 months ago.]
            • 15558
            • 108 Posts
            haha.. actually i vaguely knew the dot has something to do with concatenation. Vaguely.

            Anyway thanks for the tip I managed to ignore until today !
              Sorry for that ⇧ , I'm no dev but I wanna try