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

    Im a noob so please bear with me.

    I basically have a conference with day 1 / 2 / 3 in the site tree under these there are either keynotes / sessions / breaks all of which have different templates.

    I have tried a number of ditto modifications but all have failed.

    For each day I want to loop through and for each sibling resource if it is a session return that chunk containing those tv’s, if its a keynote return that chunk and those tv’s and the same for a break.

    Is this possible with ditto if so any suggestions on using it to swap templates in the same loop or any other suggestions?

    Thanks in advance.

    Steve
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You could use Ditto’s built-in phx functionality to select which part of the Ditto tpl to use, depending on a TV perhaps. Take a look a the default Jot "comment" display tpl to see a complex example of using phx to control the output.
        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
        • 37044
        • 68 Posts
        Thanks for the pointer but both these look pretty complicated..

        I was hoping to do something like have...

        On the actual page have a dito call like:

        [[Ditto? &parents=`340` &tpl=`conference_item`]]

        Then have an empty template ’conference_item’

        Then a chunk that references a snippet


        like - [[conf-item-switcher]]

        Then a snippet like

        <?php

        //get template name
        $templateName = $modx->db->getValue(’SELECT templatename FROM ’.$modx->getFullTableName(’site_templates’).’ WHERE id=’.$modx->documentObject[’template’]);

        $output =’’;

        //loop through if / else to match the template name and then return a template accordingly.
        if($templateName == ’conference-program-break’){

        $output .=’Template is break [*break-tv*]
        ’;

        }elseif($templateName == ’conference-program-keynote’){

        $output .=’Template is keynote [*keynote-tv*]
        ’;

        }else{

        $output .=’Template is default [*default-tv*]’;
        }

        return $output;
        ?>

        But this doesnt seem to work.

        Any other suggestions welcome!!

        Thanks
        Steve