We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41931 ☆ A M B ☆
    • 38 Posts
    Roca Oliveira Reply #1, 13 years ago
    Hi, all

    I need help urgent is possible

    I need to list several records with different templates

    [[Ditto? &startID=3 &tpl=`[+mytemplate+]` ]]


    I saw some examples like the above listed variables taking a TV but could not make it work

    Any suggestions?
      • 13428 ☆ A M B ☆
      • 1,031 Posts
      Do you want to change the record template in each row? Or do you want to change the template for the whole Ditto call?

      Your call above could be used if you want to change the template for a whole Ditto call with a template chunk name in a TV (maybe you have to call this TV by [*mytemplate*] – this depends where you are using it – [* *] in a template/document content and [+ +] i.e. in a Ditto template).

      If you want to switch the record template in each row, you could use the PHx (by PHx plugin or by using the built in PHx parser of Ditto). Example: [+template:eq=`1`:then=`xxx`:else=`yyy`+] would switch the output to xxx if the resource template is 1 and to yyy elsewhere.
        • 41931 ☆ A M B ☆
        • 38 Posts
        Roca Oliveira Reply #3, 13 years ago
        Hi, Jako

        I need to change the model for each row where &tpl= needs to be dynamic

        Thanks



          • 41931 ☆ A M B ☆
          • 38 Posts
          Roca Oliveira Reply #4, 13 years ago
          Could you give me a more practical example of how to use the PHX, I will use only two types of templates

          Eg: template1 and template2
            • 13428 ☆ A M B ☆
            • 1,031 Posts
            Which TV/DocVar should be used to switch the template?
              • 41931 ☆ A M B ☆
              • 38 Posts
              Roca Oliveira Reply #6, 13 years ago
              Tv = mytemplate
                • 13428 ☆ A M B ☆
                • 1,031 Posts
                Simple Example:
                [+mytemplate:eq=`aaa`:then=`xxx`:else=`yyy`+]


                xxx and yyy could be normal text or call chunks with {{chunkname}} and so on.

                There is a page in RTFM for PHx (http://rtfm.modx.com/extras/evo/phx). You don't have to install the plugin if you only want to use the syntax in Ditto. But if you want to use your own custom modifiers, you have to install the plugin.

                  • 41931 ☆ A M B ☆
                  • 38 Posts
                  Roca Oliveira Reply #8, 13 years ago
                  Thanks, Jako

                  I will test and give feedback
                    • 41931 ☆ A M B ☆
                    • 38 Posts
                    Roca Oliveira Reply #9, 13 years ago
                    Quote from: Jako at Nov 04, 2013, 06:26 AM
                    Simple Example:
                    [+mytemplate:eq=`aaa`:then=`xxx`:else=`yyy`+]


                    xxx and yyy could be normal text or call chunks with {{chunkname}} and so on.

                    There is a page in RTFM for PHx (http://rtfm.modx.com/extras/evo/phx). You don't have to install the plugin if you only want to use the syntax in Ditto. But if you want to use your own custom modifiers, you have to install the plugin.

                    A doubt, what would this variable eq= ?
                      • 20413
                      • 2,877 Posts
                      eq=`aaa` should be is=`aaa` :)


                      Ditto have PHx built in
                      http://rtfm.modx.com/extras/evo/phx
                      http://wiki.modxcms.com/index.php/PHx

                      with MODX1012 we have an If snippet
                      [[if? &is=`[*parent*]:is:5` &then=`@TPL:chunk-name`]]


                      Or create the perfect code:
                      https://forums.modx.com/thread/2299/alternative-to-phx-for-conditional-statements#dis-post-14903
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower