We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19156
    • 8 Posts
    Hi
    I’m new to ModX (and PHP) - and about to reveal it wink - and i’m trying to make a snippet that returns the description field of the current document: I tried somthing like this:

    if(!isset($pid) || $pid == ’’)
    {
    $pid = $etomite->documentIdentifier; //current document
    }

    //current document
    $current = $etomite->getDocument($pid,’description’);


    return $current;

    I call it like this: [[getDescription]] - and nothing happens.

    Any suggestion?

    Thanks ind advance...
      • 15987
      • 786 Posts
      Meta,
      the getDocument function returns an array so you would need to return the value like this:

      return $current['description'];
      


      If all you want to do is display the description on the current page you don’t need a snippet though. You can use the Document-Specific Template Variable [*description*]

      Here is a link to all of the Document-Specific Template Variables: http://modxcms.com/document-variables.html

      For future reference, you should replace all $etomite calls with $modx.
        • 19156
        • 8 Posts
        Thanks a lot! The template variable was exactly what I was looking for...