We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13629
    • 23 Posts
    I don’t fully understand how snippet calls from within chunks are different than regular snippet calls or why they’re even different. I’m trying to reference a template variable in a chunk’s snippet call. The TV is called "navFilename" and here’s what I’m doing:

    [+navFilename+]
    [[IncluderSnippet? &file=`assets/somefolder/views/nav/[*navFilename*]`]]
    

    The one that just gets printed out works fine. In the snippet call, though, the [*navFilename*] part doesn’t work and MODx tries to include assets/somefolder/views/nav/, which obviously doesn’t work.

    Is it possible to do something like what I’m trying to do?

    Thanks,
    Jason
      • 10487 MODX Staff
      • 1,535 Posts
      Garry Nutting Reply #2, 18 years ago
      Is this just a normal chunk call or is it part of, say, a Ditto call? I’m not sure why you are using [+navFilename+] and then [*navFilename*] - if [+navFilename+] works, then why not use that in the snippet call?
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 13629
        • 23 Posts
        The [+navFilename+] notation doesn’t work within the context of the snippet call.
          • 10487 MODX Staff
          • 1,535 Posts
          Garry Nutting Reply #4, 18 years ago
          Okay, so assuming that [+navFilename+] is being set somewhere as a placeholder, could you adjust the Includer snippet to have an optional &ph option, like:
          [[IncluderSnippet? &file=`assets/somefolder/views/nav/` &ph=`navFilename`]]

          And then, check for that parameter in the Includer snippet using something like:
          ...
          $ph = isset($ph) ? $modx->getPlaceholder($ph) : null;
          if ($ph != null) $file = $file.$ph;
          ...

          I’m not fully understanding if navFilename is a TV or a placeholder, I’m going with placeholder seeing as [+navFilename+] works for you. A bit more info on how you are calling/processing the chunk would be useful if the above doesn’t work.
            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com