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

    I’m trying to give clients some options for controlling the layout of a jQuery slider using dropdown lists. I’m not sure if my approach is right but here’s what I’m doing.

    I have a hero element in my template which is controlled by a TV dropdown list like this:
    No Hero Element=={{blank}}||Hero Image - Choose Image Below=={{heroImageChunk}}||Hero Slider - Use Hero ID Below For Content=={{slider}}


    The first two work as expected but the last option, Hero Slider throws up the classic Ditto error:
    &tpl either does not contain any placeholders or is an invalid chunk name, code block, or filename. Please check it.


    I suspect the reason is because the Slider has several configurable options that are nested too deep maybe? Not sure. The {{slider}} chunk above contains:
    <!-- START HERO -->
    <div id="hero" class="centre">
    
    [*sliderSelector*]
    
    <!-- CLEAR FLOATS ABOVE -->
    <br class="clearFloat" />
    <!-- END HERO -->
    </div>

    [*sliderSelector*] is a dropdownlist:
    Next & Back Buttons Top=={{sliderButtonsTopDitto}}||Next & Back Buttons Bottom=={{sliderButtonsBottomDitto}}||Navigation Menu=={{sliderNavMenuDitto}}


    If we take the first option, {{sliderButtonsTopDitto}} it looks like this:
    <!-- SLIDER NAVIGATION -->
    <div class="sliderButtons">
    {{sliderButtonsTpl}}
    </div>
    <!-- END SLIDER NAVIGATION -->
    
    <!-- SLIDER PANES --> 
    <div id="sliderPanes">
    <!-- SLIDER ITEMS --> 
    <div class="items"> 
    [!Ditto? &parents=`[*sliderID*]` &showInMenuOnly=`[*sliderShowInMenu*]` &tpl=`[*sliderLayout*]` &orderBy=`menuindex ASC`!]
    <!-- END SLIDER ITEMS -->
    </div> 
    <!-- END SLIDER PANES -->
    </div>
    


    The &tpl=`[*sliderLayout*]` is another dropdown list that lets the client decide a few options like this:
    Images Only=={{sliderImagesTpl}}||Images Only With Links=={{sliderImagesLinksTpl}}||Text & Images=={{sliderTextImagesTpl}}||Text & Images With Links=={{sliderTextImagesLinksTpl}}
    


    The {{sliderImagesTpl}} chunk looks like this:
    <div>
    <img src="[+heroImage+]" alt="[+heroImage+]" class="fullImage" width="959" height="380" />
    </div>


    As you can see I also have a few TV drop down lists configuring options in the Ditto call - is this OK? As far as I can tell from the outputted HTML, Modx is successfully parsing the first 3 levels and seems to be parsing the Ditto call but not the template - is that correct?

    Is this the right way to provide clients with these kinds of options or is there a better way that doesn’t require so much nesting.

    Any help would be much appreciated.

    Cheers

    Ben
      • 5532
      • 251 Posts
      If I place the template chunk into the ditto call it works.

      So instead of this:
      &tpl=`[*sliderLayout*]`


      I have this:
      &tpl=`sliderTextImagesTpl`


      So I guess I’ve reached the limit of the Modx Parser - I was reading it would go round 10 times but obviously I’m misunderstanding the basics? I’m also not convinced this is the best way to set up options like this so any pointers would be much appreciated.

      Cheers