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

    is it possible to use a variable in a chunk directly? Right now if i have a chunk of HTML, and i want to replace one string in it, i have to write a dedicated snippet that parses the chunk and replaces the placeholder. It would be easier if i can directly replace the placeholder in the chunk by calling the chunk with a parameter from within the content?

    Olaf
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Chunks are simply small ...er, chunks of HTML and/or text that get inserted into the document’s regular content. Their purpose is to contain blocks of content that can be common across templates (such as a page footer, or the site’s masthead) so it can be edited in one place.

      They don’t have any code or other processing at all. If you want a chunk with conditional output, you’ll have to have it contain a snippet or TV.

        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: olafmol at Aug 21, 2008, 02:56 AM

        Hello,

        is it possible to use a variable in a chunk directly? Right now if i have a chunk of HTML, and i want to replace one string in it, i have to write a dedicated snippet that parses the chunk and replaces the placeholder. It would be easier if i can directly replace the placeholder in the chunk by calling the chunk with a parameter from within the content?

        Olaf
        That’s what placeholders are for. You just need to set the placeholder before the chunk is parsed and make sure the chunk content does not get cached in the page.
          • 25663 MODX Staff
          • 12,272 Posts
          In all fairness and to reiterate yet-another-cool-thing-of what’s-coming with Revolution, you can do it as follows:

          [[$MyChunk? &name=`Bob`]] where it replaced [[+MyChunk.name]] in your MyChunk chunk (note the new syntax for chunks/placeholders).

          (So get to testing it and give us feedback so we can get to Beta and RC sooner!)
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 22098
            • 218 Posts
            Quote from: rthrash at Aug 21, 2008, 08:58 PM

            In all fairness and to reiterate yet-another-cool-thing-of what’s-coming with Revolution, you can do it as follows:

            [[$MyChunk? &name=`Bob`]] where it replaced [[+MyChunk.name]] in your MyChunk chunk (note the new syntax for chunks/placeholders).

            (So get to testing it and give us feedback so we can get to Beta and RC sooner!)

            that was what i was looking for, sounds cool wink