We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40728
    • 29 Posts
    Hey all,

    I have a bunch of problems using gallery, hope you can help.

    i created a TV to display an image, like in the example. input: galleryitem, output: galleryitem.

    First off, when I set the output to "galleryitem", below the output type dropdown I get this error:

    Notice: Uninitialized string offset: 0 in /home/sibrand/public_html/modx/core/components/gallery/elements/tv/properties/galleryitem.php on line 49


    The code there is a bit too abstract for me to know what's going on or how to fix it.

    Moving on.
    When I want to use this gallery+tv to attach an image to my blogpost, all is fine on the article page, the image shows up.

    However, in a listing on the homepage, I have a list of recent blogposts and in the chunk used to display the item, there's the same TV to display the galleryimage.

    But in this list, the image doesn't show up.


    code of the listing template:
    [[getResources? 
    &parents=`7` 
    &showHidden=`1` 
    &tpl=`article-grid-view` 
    &limit=`8` 
    &offset=`0` 
    &includeTVs=`1`
    &processTVs=`1`
    &tvFilters=`articlestags==%featured%`]]
    


    chunk (article-grid-view):
    <li class="panel grid_4">
    	<a href="[[~[[+id]]]]">
    		[[*blogimage]]
    		<h4>[[+pagetitle:ellipsis=`50`]]</h4>
    		<p>[[+introtext:default=`[[+introtext:ellipsis=`10`]]`]]</p>
    	</a>
    </li>
    


    In the settings for Articles, I have Include TVs in listing and process TVs in listing both set top YES.

    How do I fix this? [ed. note: dieomesieptoch last edited this post 11 years, 8 months ago.]
      • 40728
      • 29 Posts
      Anybody here?

      update

      I get this php error in my website: Notice: Undefined index: gal_id in /home/sibrand/public_html/modx/core/components/gallery/elements/tv/output/galleryitem.php on line 35

      and in the place where the images are supposed to show up, I get this:

      {"gal_src":false}


      the funny thing is, when I remove the &tpl parameter, the raw array is dumped along with the actual image where the array key says [tv.blogimage] =>

      but the php error is persistent. I'm assuming a gallery ID can;t be passed to the code since you want to select the blog image in the backend.

      What am I doing wrong?
        • 39758
        • 2 Posts
        Hello dieomesieptoch

        Sorry for my English

        GetResources tvs need prefix. By default is tv, so in principle your chunk would be:

        <li class="panel grid_4">
            <a href="[[~[[+id]]]]">
                [[+tv.blogimage]]
                <h4>[[+pagetitle:ellipsis=`50`]]</h4>
                <p>[[+introtext:default=`[[+introtext:ellipsis=`10`]]`]]</p>
            </a>
        </li>


        you can see at addon page: http://rtfm.modx.com/display/ADDON/getResources [ed. note: mikelazpilikueta last edited this post 11 years, 8 months ago.]
        • (just for your information, "suffix" comes at the end of a word, "prefix" comes at the beginning of a word)
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 39758
            • 2 Posts
            sorry for the mistake, I've corrected.
              • 40728
              • 29 Posts
              Thank you!!

              Wow, I actually have tried namespacing, but I guess only using the [[*tv.blogimage]] notation.
              It works now, thanks!

              I'm a little confused, how does the * sign in that case turn into a + sign?

              (I used this document to display images on my blogpost pages: http://rtfm.modx.com/display/ADDON/Gallery.Setting+Up+the+GalleryItem+TV )
              • The * sign indicates the TV (or resource value) for THIS resource... the one being looked at, the one that was originally requested, such as home.html

                The + indicates a placeholder. These are in an array populated with values by the snippet being used, and are used by the snippet to display the value for the resource the snippet is processing at the moment (such as "blog page 1"). The snippet processes a whole set of resources, according to the properties you gave it telling it where to get its list of resources. Then it applied its chunk tpl to each resource in its list, replacing the placeholder with the proper value for that resource.

                So if you used *pagetitle in that chunk tpl, it would always display the page title of the page you are on (for example, Home), while + would display the page title for each resource being listed.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org