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

    one simple question: is it possible to call a different chunk from within a chunk?

    Chunk:
    "<p>{{contentchunk}}</p>"

    This is a massively simplified example. In fact, I want to use it with wayfinder. I need some row templates, and the "here versions" of the rows need additional Javascript.

    Here Template:
    "<script>...</script>
    {{rowTpl}}"

    Is this possible?
      • 1343 ☆ A M B ☆
      • 2,213 Posts
      I don’t know if it will work, but it should be easy enough to test. Granted you could include the JS code in the wayfinder chunk and skip calling an external chunk which simplifies things.

      AMDbuilder
        Patrick | Server Wrangler
        About Me: Website | Tweets |  MODX Hosting
        • 10313
        • 375 Posts
        Well, i have explained unclearly. I have already tested it like I posted above. It did not work. That’s why I posted my question. I meant: Is there a way to use chunks in a chunk?
          • 34162
          • 1 Posts
          A chunk within a chunk can work (I’ve used it before), but when I see your example, I suspect you call a chunk that’s meant to be a template for Wayfinder, right?

          I mean, you’ll probably have some placeholders of Wayfinder in there, and I’m not sure it can work that way.
            • 29774
            • 386 Posts
            You can use a ’chunk in a chunk’ if it get’s parsed by the modx parser. In this instance you’re passing the chunk to a snippet and the snippet is parsing the chunk ’locally’. As snippet parsing occurs after the modx parser has parsed chunks, your {{chunk}} will simply get removed in the final clearup before the document is output.

            The solution is to use the PHx plugin. You can use PHx with Wayfinder by using the special phx:input method to modify your placeholders in your template:

            [+phx:input=`[+myplaceholder+]`:modifier1:modifier2+]

            The modifier can be any of the built in ones or a custom phx modifier (ie a snippet called phx:mymodifiername that transforms and returns a variable called $output). Which means you can basically run any php code.

            See:
            http://wiki.modxcms.com/index.php/PHx
              Snippets: GoogleMap | FileDetails | Related Plugin: SSL
              • 10313
              • 375 Posts
              Thanks for the hint. I’m now using

              <script>
              current1 = [*id*];
              </script>
              [+phx:input=`dl_row`:getChunk+]
              


              as rowHereTpl. The PHx-line adds the rowTpl. So I don’t have to do my changes in the template twice. Once for the row, once for the HereRow.

              But: This does not work. The added rowTpl is not parsed by Wayfinder any more.

              EDIT: I have installed the 2.5 beta of Wayfinder, and now it works. Thanks for helping!

              Martin