We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21484
    • 23 Posts
    If I use placeholders in a file that is included in a chunk with a php include over a snippet, the placeholders are not interpreted.

    Example: [[+value]] doesn´t works in an external file. [[*value]] works well in an external file.

    This works fine for template variables but not for placeholders. If I copy the content of the file into the textarea for the chunk in the manager, all things are working well.

    What can be the reason for this behaviour?
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: niepro at Sep 24, 2010, 12:00 PM

      If I use placeholders in a file that is included in a chunk with a php include over a snippet, the placeholders are not interpreted.
      I don’t understand what you asked here. You can’t "include" a file in a chunk, so some clarity is needed before we continue to help you solve your issue. Perhaps you could try posting your chunk and/or snippets here (or a pastebin or gist or...) for a better understanding.
        • 21484
        • 23 Posts
        Oh, sorry for that.

        I will try it again.

        I´ve done some more tests in the meantime.

        This is my template code:
        [[$includeSomething? &myPlaceholder=`hello world`]]


        Here is my chunk code for the chunk includeSomething:
        The output of the placeholder inside the chunk code: [[+myPlaceholder]]
        [[!includeSomething]]
        


        And this is my snippet code for the snippet includeSomething:
        return 'The output of the placeholder inside the snippet code: [[+myPlaceholder]]';


        The problem is, that the placeholder in the first line of the chunk code are interpreted, not so the placeholder included from a snippet.
          • 3496
          • 101 Posts
          I think you have two problems:

          • The first one is a scope-issue; you need to pass the parameter to the snippet, like this:
          The output of the placeholder inside the chunk code: [[+myPlaceholder]]
          [[!includeSomething? &myPlaceholder=[[+myPlaceholder]]]]

          • The second issue is how to retrieve the paramter in the snippet; you have to retrieve it as if it’s an ordinary PHP-variable:
          return ’The output of the placeholder inside the snippet code: ’.$myPlaceholder;
            • 21484
            • 23 Posts
            Thanks. But this is not what I need.

            I want, that the string from the snippet will be processed like the code I directly put into the chunk. The Background is, that the string will be from a file and I can write the code in an extern editor, can use SVN and so on.

            I know that this should work. The only thing is, that the [[+somthing]] doesn´t change to the value defined for this placeholder. What works is the Template Variable [[*someTV]].
              • 3749
              • 24,544 Posts
              You might look into the @FILE binding for template variables. The template variable tag will then pull in the contents of the file.
                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