We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38310
    • 23 Posts
    Hi, Guys. How to use the @CODE which can output the html string in Ditto syntax? Please give me an syntax example. Thanks very much.
      • 36404
      • 307 Posts
      hi,

      something like
      $tpl=`@CODE<div>[+content+]</div>`

      pretty basic but put whatever html and placeholders you want between `@CODE and ` smiley

      have swing
        réfléchir avant d'agir
        • 38310
        • 23 Posts
        Syntax01:
         [[Ditto? &documents=`123,124` &tpl=`@CODE<h1>[+pagetitle+]</h1>`]]  
        This works.
        Syntax02:
         [[Ditto? &documents=`123,124` &tpl=`@CODE<img src="[+photo1+]">`]] 
        This does't work.
        Syntax03:
         <img src="[[Ditto? &documents=`123` &tpl=`@CODE[+photo1+]`]] " >    
        This works.
        Why when the string behind the @CODE include the ",= parameters it doesn't work?
        [ed. note: welkang last edited this post 14 years, 4 months ago.]
          • 3749
          • 24,544 Posts
          The MODX Evolution parser can't handle equal signs (or ampersands) inside the backticks.
            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
            • 38310
            • 23 Posts
            Thanks very much.
            There is a situation that I want to iterate some simple like img elements html string through the Ditto snippet, I must to creat a chunk which only included the little codes. I think this is not very convenient for us. Is there any easy way to do this?
            I'm a evolution version user.
              • 16278
              • 928 Posts
              There are two ways you can include computed values in your template, PHx and config files. Without more details, such as what the input variables for selecting the images are, it's difficult to say what would suit your purpose better.

              PHx is in common use, and is well documented in the Wiki and in RTFM. Ditto includes its own copy of PHx, so no there's need to install the plugin. See also http://www.pogwatch.com/ditto/ditto-phx.html

              A config file allows you to use computed parameters through a PHP file. Include a Ditto parameter such as &config=`myTpl`, and Ditto will assign parameter values according to the code in the file /assets/snippets/ditto/configs/myTpl.config.php. See http://www.pogwatch.com/ditto/ditto-config.html for more on using config files.

              :) KP

                • 36416
                • 589 Posts
                Quote from: kp52 at Jun 18, 2012, 03:53 AM

                A config file allows you to use computed parameters through a PHP file. Include a Ditto parameter such as &config=`myTpl`, and Ditto will assign parameter values according to the code in the file /assets/snippets/ditto/configs/myTpl.config.php. See http://www.pogwatch.com/ditto/ditto-config.html for more on using config files.

                Mostly go for the config files to better organize and track changes of your "views"... wink