We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10940
    • 71 Posts
    Can you set the default value of a TV (plain-text field) to be the current document ID?
      • 3749
      • 24,544 Posts
      Try setting it to:
      [*id*]


      I’m not sure if it will be parsed in time or not. You’d have to try it.

      FYI, if you just need the ID, you can use the [*id*] tag directly rather then using a TV.

        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
        • 10940
        • 71 Posts
        Thanks BobRay.

        What I’m trying to do is have ditto call that lists media releases.

        Problem is some media releases will be internal, and therefore will require a read more anchor
        link that goes through to the article but some will be external and therefore will need
        an anchor link to go whatever the client enters in the TV.
          • 3749
          • 24,544 Posts
          I see your problem. The tag I used above should probably be

          [~[*id*]~]


          since you want an actual URL rather than the ID.

          If that doesn’t work, using PHX might. You could have a special value for the TV if it’s an internal link (e.g. "Internal") and the URL itself if it’s not. The Ditto Tpl chunk would look something like this:

          [*TvName:is=`Internal`:then=`[~[*id*]~]`:else=`[*TvName*] *]


          I’m still not sure it would work, though.

          The only thing I can think of that would work for sure is to just put the actual URL (local or foreign) in the TV.
            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