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

    Is there a way to get chunk names and description inside themselves ?
      MODX lover
      Développeur MODX / Webdesign / Solutions web
      • 17301
      • 932 Posts
      Can you explain a little bit more what you're trying to do?
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 38783
        • 571 Posts
        If you are trying to display the Description of a Chunk in the front end as part of your page content then a snippet like this would display the chunk Description. A modified version of this snippet could probably display the chunk Name.

        //[[!getChunkDescription? &chunkname=`myChunk`]]
        if ($chunk=$modx->getObject('modChunk',array('name'=>$chunkname))){
            return $chunk->get('description');
        return '';

        But if I have misunderstood your aim, as LK says, could you explain a bit more. [ed. note: andytough last edited this post 6 years, 2 months ago.]
          If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

          email: [email protected] | website: https://andytough.com
          • 46580
          • 167 Posts
          Thank you for your reply.
          I'd like to get chunk name inside the chunk itself.
          The purpose is to add a debug mode allowing fast chunk identification.
            MODX lover
            Développeur MODX / Webdesign / Solutions web
            • 3749
            • 24,544 Posts
            I can't think of an easy way. If the chunk is being pulled in with a chunk tag, you might be able to use a plugin attached to OnLoadWebDocument that finds the chunk tags with a regex, then writes or displays it somewhere.

            Possibly a better way is to add a snippet like this to the chunk:

            [[!ShowName? &chunkName=`actualNameOfChunk`]]

            /* ShowName snippet */
            if ($modx->user->get('id') == 1) { // adjust ID as necessary
                return $modx->getOption('chunkName', $scriptProperties, '');
            return ''

            The name will only show for the user with the specified ID.
              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