We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22897 ☆ A M B ☆
    • 209 Posts
    I’m listing documents and web links using Ditto.

    The documents have a TV file input, and their link needs to point to that file.
    The web links need to link to the external website.

    Is there any way to do this with Ditto? I can’t find any way to provide different chunks depending on the document type, or to embed this logic.

    Thanks,
    Peter
      MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
      • 15871
      • 105 Posts
      You could use PHx inside the template chunk like so:

      <code>
      [+type:is=`document`:then`<a href="[+fileLink+]">[+fileLink+]</a>`:else=`< a href="[+weblink+]">[+weblink+]</a>`+]
      </code>

      That should work. Essentially it looks to see if the doctype is a document and swaps a different HREF for it.
        • 22897 ☆ A M B ☆
        • 209 Posts
        Thanks, I’ve yet to get into using Phx. I did the same thing the ’traditional’ way by writing a custom snippet.
          MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!