We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3295
    • 19 Posts
    I am looking for suggestions for solving my problem. I want to dynamically call images into chunk based on a parent ID. the images are from a image TV associated with a page template. Basically one image get placed onto a page which is a child, if there are 5 pages than 5 images would get displayed in a chunk based on the id associated with the parent, if there are 10 pages, than 10 images would get pulled into the chunk. The id would be declared in a template with a ditto call. Does this make any sense?


    How could I do this? I have included some wireframe images for the flow of the content... I am stuck and have spent along time digging and looking for a solution.

      • 3749
      • 24,544 Posts
      Someone else may suggest an easier way (possibly Ditto would do it), but you could do it with a snippet that uses:
      getDocumentChildrenTVars ([ $parentid = 0], [ $tvidnames = array()], [ $published = 1], [ $docsort = "menuindex"], [ $docsortdir = "ASC"], [ $tvfields = "*"], [ $tvsort = "rank"], [ $tvsortdir = "ASC"])


      To make it extend past one level, I think you’d also have to use this:

      getDocumentChildren ([ $parentid = 0], [ $published = 1], [ $deleted = 0], [ $fields = "*"], [ $where = ''], [ $sort = "menuindex"], [ $dir = "ASC"], [ $limit = ""])


      In order to group them properly, you may want a different snippet on the main page.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 3295
        • 19 Posts
        Cool, thanks. I would put that code into a snippet and name it something [[SnippetName]]

        Then I would call the snippet into the template? Is that right...
          • 3749
          • 24,544 Posts
          Right.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 3295
            • 19 Posts
            Great, thanks! I am going to mess with it now.


              • 3295
              • 19 Posts
              Is this what the snippet call in the template could look like?

              [[imageReuse? &parentid=`10` &tvidnames=`[*product-image*]` &published=`5`]]


              I was playing with it but I have gotten no results good or bad. Which stinks because if it breaks it at least I know something is happening wink

              Thanks
                • 3749
                • 24,544 Posts
                Quote from: bicyclenerd at Nov 05, 2009, 06:34 PM

                Is this what the snippet call in the template could look like?

                [[imageReuse? &parentid=`10` &tvidnames=`[*product-image*]` &published=`5`]]


                I was playing with it but I have gotten no results good or bad. Which stinks because if it breaks it at least I know something is happening wink

                Thanks

                I’m not sure what you’re doing with those parameters, but I suspect you want:

                &tvidnames=`product-image`


                if you want to send the name of the TV you’re using to the snippet.

                And &published is usually set to 1 or 0 (1 meaning show only published docs, 0 meaning show all docs) unless you’re using it for something other than the usual purpose.

                It’s hard to know without seeing your snippet code.

                Getting no output at all sometimes means that you’ve got the name of the snippet wrong in the tag (name is case-sensitive).

                Try putting this code at the top of the snippet:

                return "Snippet is Executing";


                to make sure it’s actually executing (don’t forget to remove it).

                Another reason for getting no output is forgetting to return any in the snippet:

                $output = 'what you want output';
                return $output;


                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 3295
                  • 19 Posts
                  I have been unsuccessful with this, I just want to say that I am very new to programming especially PHP so any further help would be awesome. I am trying really hard to learn PHP and apply it but I am struggling. How would write this snippet?

                  Thanks.
                    • 3749
                    • 24,544 Posts
                    Quote from: bicyclenerd at Nov 10, 2009, 09:12 AM

                    I have been unsuccessful with this, I just want to say that I am very new to programming especially PHP so any further help would be awesome. I am trying really hard to learn PHP and apply it but I am struggling. How would write this snippet?

                    Thanks.

                    The best thing is to post the snippet code here so we can see what you’re trying to do and spot potential errors.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 3295
                      • 19 Posts
                      I have to be honest, I really have nothing. I am just learning this stuff and I have no clue where to even begin. Thanks for your help though, perhaps if I can ever get started I will post something up. I thought I would be able wrap my head around php and this stuff, but I am not getting it.

                      Thanks.