We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10226
    • 412 Posts
    It has been about six months since I have had to do back-end work in modx and things are not so fresh for me. I am working on something that requires dynamic data to be populated in the <head>. Of course, Ditto is up for the task. But I am thinking I might run into problems. This method will cause me to have a dynamic template. What is the best way to handle this?

    Thanks!
      • 4310
      • 2,310 Posts
      What type of data?
      Something from the database or elsewhere?
        • 10226
        • 412 Posts
        Yeah more info would be helpful smiley

        This is for a slideshow, so I will need to be specifying a varied amount (this is why Ditto comes to mind) of ’pictures’ and of course multiple pieces of info for each. The info will be in the main database - if not, I’m backing out right now. All I know is that this can be tricky, might require placeholders and may be buggy sad So I am trying to wrap my head around the easiest way to make this happen... A document (folder) to hold the child docs that hold the picture info under every top level menu item is what I am thinking. No more than 5 pictures should be used, so it will be manageable. That might not make sense, so here is a visual..

        "HOME PAGE"
        SlideshowHolder
        pic1
        pic2
        ChildDoc1


        "OTHER PAGE"
        SlideshowHolder
        pic1
        pic2
        pic3...


        Each top level menu item will have a set of pictures and second level items will also grab the same set of pictures, unless I specify something else - ok that is where it might get a bit tricky, but I’m not there yet.

        So I guess the question is how do I call Ditto in the <head> of the template! - And get proper results. Otherwise, I will need a hand-mod static template for all of the top level menu items.
          • 4310
          • 2,310 Posts
          There are several ways of achieving what you’re outlining, to help narrow it down:
          When yo say info do you mean there is a lot of text to go with each picture?
          Do you have a link to a demo of the slide show?
          More questions without answers!
            • 10226
            • 412 Posts
            here is the slideshow link - http://www.electricprism.com/aeron/slideshow/ - now what it needs in the head is the picture, and the description and something else I am sure...

            here is the code that needs to be in the head...

            <script type="text/javascript">		
            	//<![CDATA[
            	  window.addEvent('domready', function(){
            	    var data = {
            	      'plants.jpg': { 'caption': 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.' },
            	      '2.jpg': { 'caption': 'Quisque ut neque. Nam ultricies.' },
            	      }
            	    
            	    var myShow = new Slideshow('my_show', data, { captions: true, controller: true, hu: 'images/' });
            	  });
            	//]]>
            	</script>
            


            Thats fairly simple and you can quickly see why I would like to use ditto for this smiley
              • 10226
              • 412 Posts
              Well I’m a bit stuck right now... I want to use the Ken Burns version of this slideshow http://www.electricprism.com/aeron/slideshow/ - but there is so much script in there, it is hard for me to see what parts I need. Do I even need to populate the data in the head, or can I use a basic list. Looking at firebug and watching the show, it is very confusing to me :/

              Thanks
                • 4310
                • 2,310 Posts
                Why not put that js in a chunk, creating a duplicate chunk for each set of pictures, with the relevant pics details, captions etc.
                Name them {{slidesHome}}, {{slidesContact}} maybe create a default version for all other pages {{slidesDefault}}
                Then create this snippet:
                <?php
                global $modx;
                $output = '';
                $docid = ($modx->documentIdentifier);
                if ($docid == 1) {
                $output .= '{{slidesHome}}';
                }
                if ($docid == 2) {
                $output .= '{{slidesContact}} ';
                }
                else
                $output .= '{{slidesDefault}}';
                return $output;
                ?>
                

                Call it [[SlideShow]] and put it in the <head> of your template.
                Just duplicate
                if ($docid == ?) {
                $output .= '{{slides?}} ';
                }
                for each document you want a unique slide show for.
                  • 10226
                  • 412 Posts
                  That is exactly what I want to avoid, That in fact was my first idea, but it would be a pain to update the pictures... Right now I am worried about getting the code right for what I want. The slideshow plays in an area with a witdh of around 200 px, so I really want to pan and zoom.
                    • 7455
                    • 2,204 Posts
                    i made a snippet that does that ken burns effect etc.
                    http://modxcms.com/forums/index.php/topic,21962.0.html

                    Dimmy
                      follow me on twitter: @dimmy01
                      • 4310
                      • 2,310 Posts
                      Nice snippet Dimmy, I’ll try it myself!