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

    I am new to this so please bear with me......

    Have been trying to use the Galeryitem to form information in the way I want, for example: If I create a new TV and set the Input and Output to GalleryItem, when a call the TV in my chunk as such

    [[*GalleryItemTV]]


    Then this creates a img tag as follows:

    <img src="/assets/components/gallery/connector.php?action=web/phpthumb&w=0&h=0&zc=0&far=&q=90&src=%2Fassets%2Fgallery%2F1%2F8.jpg" alt="Residential" title="" class="three-columb-img">


    If I change the output to text I get the following:

    {"gal_src":"/assets/gallery/1/8.jpg","gal_id":8,"gal_name":"Residential","gal_description":"Sketch Drawing Of A Residential Property","gal_image_width":292,"gal_image_height":200,"gal_orig_width":292,"gal_orig_height":200,"gal_album":"1","gal_watermark-text":"","gal_watermark-text-position":"BL","gal_other":"","gal_rotate":"0","gal_sizer":100,"gal_cropCoords":"","gal_cropTop":0,"gal_cropRight":0,"gal_cropBottom":0,"gal_cropLeft":0,"gal_class":"three-columb-img"} 


    Now I followed this post https://forums.modx.com/thread/50588/tv-galleryitem-extract-image-path-description as I wanted to use certain elements from the GalleryItem but to do so it required I pass the id.

    So my code ended up being something like this:

    [[!GalleryItem? &id=`[[!getPicId? &imageTV=`[[*bannerImageOne]]`]]`]]
    						<img src="[[+galitem.image]]" alt="[[+galitem.name]]" title="[[+galitem.description]]" class="three-columb-img"/>


    Where getPicId is a snippet as follows:

    <?php
    $obj=json_decode($imageTV);
    return $obj->gal_id;


    The problem I am getting with the above is that when I try to use different galitem items I don't get what I expect as following code shows:

    description =[[+galitem.description]] </br>
    name = [[+galitem.name]] </br>
    filename =[[+galitem.filename]] </br>
    description = [[+galitem.description]] </br>
    mediatype = [[+galitem.[mediatype]] </br>
    createdon = [[+galitem.createdon]] </br>
    createdby = [[+galitem.createdby]] </br>
    active = [[+galitem.active]] </br>
    albums = [[+galitem.[albums]] </br>
    tags = [[+galitem.tags]] </br>
    url = [[+galitem.url]] </br>


    Giving:

    name = Residential
    filename =8.jpg
    description =
    mediatype =
    createdon = 2012-10-16 18:47:28
    createdby = 1
    active = 1
    albums =
    tags =
    url =

    Even though I have things like the description filled out it doesn't output, and what if I want the class? What If I just wanted the path as

    /assets/gallery/1/8.jpg

    instead of

    /assets/components/gallery/connector.php?action=web/phpthumb&w=0&h=0&zc=0&far=&q=90&src=%2Fassets%2Fgallery%2F1%2F8.jpg

    So the way I have done it is to create snippets for each bit of information I need i.e

    To get the src I created getPicSrc:

    $obj=json_decode($imageTV);
    return $obj->gal_src;


    So in the chunk, the following would give /assets/gallery/1/8.jpg

    [[!getPicSrc? &imageTV=`[[*GalleryItemTV]]`]]


    So now I can get the information I need to form the HTML in the way that I want and looking tider.

    Now I'm sure their is probably a better way of doing it, instead of creating all these snippets and snippet calls?

    Any ideas?

    Thanks in advance.