We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11075
    • 3 Posts
    Hello all,

    as stated in "Subject" I have trouble calling a Template Variable in a Chunk.
    I have a suspicion why, but I am not entirely sure.

    I am using the newest ModX Revo version (Which I fell in love with!).

    TV: introimage | Image
    This is the code in my chunk displayed in Template A, called via Ditto:

    [[+introimage]][[+introtext]]
    


    Now, this chunk is only showing the introtext of this document in Template A which is an overview template grabbing the newest article and shows an introduction.

    The introtext is displayed but the TV is not, even though it is entered and name checked.

    If I use the TV in the document itself though, it works absolutely fine, using Template B.

    I reckon simply that due to the reference to Article X on the overview page, the TV cannot be load since it is not the Article page.
    The rights in the Templates are set properly.

    Is it me, or did I miss something?

    Looking forward to your answer hoping it is in the right forum, since the searchfunction didnt bring up anything I looked for.

    Cheers,
    Gomf
      • 3749
      • 24,544 Posts
      I’m not sure, but it looks like you might be confusing placeholder tags with content field/TV tags.

      [[+placeholderName]] is a placeholder tag
      [[*introtext]] is a content field/TV tag.

      It’s easy to get these confused because many add-on components use placeholders to display content fields in their Tpl chunks.

      See if this helps:

      If you want to display a TV in a template, in a page’s content field, or in a chunk that is *not* being processed by an add-on component (e.g., getResources), you do it with a content field/TV tag:

      [[*TvName]]


      MODx will look for a content field (e.g. introtext, pagetitle, content, etc.) with that name and for a TV with that name for the current resource.

      If, instead, you are putting a tag in a Tpl chunk that will be used by an add-on component like getResources or Wayfinder to format its output, you usually need to make it a placeholder tag:

      [[+placeholderName]]


      The add-on component sets the placeholders (often by getting the content field or TV directly from the DB). You need to consult the documentation for the addon to see which placeholders are set and what their names are.

      Using a [[*field-name]] tag in a Tpl chunk, will still give you output, but it will display the value from the page containing the add-on tag (i.e., the current page) rather than the page the add-on is currently processing. That usually not what you want.

        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
        • 11075
        • 3 Posts
        Thank you for your reply bob,

        as it seem I am having a TV in a template Chunk, so the [[*XX]] notation should do it.
        But as you said, it displays from the containing and not from the processed page.

        Oh, thanks for the heads up on the notations as well.

        Anyway, how do I solve this? Atm I am thinking about building a snippet that somehow get’s the content of
        this TV by identifying the ID with [[*id]], is there already a way in place to do this?

        I’d imaging something like [[*TV &id=`[[*id]]’]], you see where this is going?

        Cheers,
        Gomf
          • 11075
          • 3 Posts
          Solved it by using getResources instead of ditto.

          [[!getResources? &parents=`[[*id]]` &tpl=`tplrev_top` &showHidden=`1` &processTVs=`1` &includeTVs=`1` &includeContent=`1` &tvPrefix=``]]

          processTVs and includeTVs did exactly what I hoped for as described here: http://rtfm.modx.com/display/ADDON/getResources

          Thank you for your help.
          Cheers,
          Gomf