We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23491 ☆ A M B ☆
    • 1,056 Posts
    Let’s say I have a SNIPPET and a CHUNK called: FOO

    I execute my snippet:

    [[FOO]]


    and I want it to do some processing, and then return the CHUNK:

    return '{{FOO}}';
    


    Here’s the question:
    How can I return the Name of the snippet being called as chunk?

    e.g.

    return '{{_SNIPPET NAME HERE_}}';
    
    // also would work well with $modx->getChunk
    


    I read through the MODx Tags, and didn’t see an attribute for referencing the called upon snippet, etc?

    Does this make sense, and can it be done?
      Mike Reid - www.pixelchutes.com
      MODx Ambassador / Contributor
      [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
      ________________________________
      Where every pixel matters.
      • 10487 MODX Staff
      • 1,535 Posts
      Garry Nutting Reply #2, 20 years ago
      You could pass the snippet name in as a parameter ... I don’t think you can access the name directly, but saying that, I’ve never really tried.

      So, have a parameter: &name=`FOO`

      And, then call it like:
      return '{{'.$name.'}}';
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 23491 ☆ A M B ☆
        • 1,056 Posts
        Interesting approach...

        I’d still have to type it twice, but at least now it’s centralized. hehe smiley

        Anyone know if this can be referenced directly?
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.
          • 10487 MODX Staff
          • 1,535 Posts
          Garry Nutting Reply #4, 20 years ago
          It’s your lucky day smiley Just checked it out and you can use: $modx->currentSnippet

            Garry Nutting
            Senior Developer
            MODX, LLC

            Email: [email protected]
            Twitter: @garryn
            Web: modx.com
            • 23491 ☆ A M B ☆
            • 1,056 Posts
            Quote from: garryn at Oct 17, 2006, 06:06 PM

            It’s your lucky day smiley Just checked it out and you can use: $modx->currentSnippet

            Too cool! You guys rock smiley

            Garry, mind posting a link for others to where you found this, or was it undocumented?
              Mike Reid - www.pixelchutes.com
              MODx Ambassador / Contributor
              [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
              ________________________________
              Where every pixel matters.
              • 10487 MODX Staff
              • 1,535 Posts
              Garry Nutting Reply #6, 20 years ago
              It’s undocumented as far as I know, I looked in the evalSnippets() function in manager/includes/document.parser.class.inc.php

              If in doubt, go to the source as they say smiley
                Garry Nutting
                Senior Developer
                MODX, LLC

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