We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22656
    • 121 Posts
    Argh! Call me stupid i just spent 30 mins googling for this info without success.
    Basically I have a chunk which calls a snippet. In the snippet I want to get the page's "menutitle" placeholder and use it in my code.

    This is what I had, i tested it and i thought it works.
    echo $modx->documentObject['menutitle']

    However, checking it today I noticed it doesnt output anything. I tried using getPlaceholder code too, no success. What am I doing wrong?

    The chunk in question is called on lots of separate pages.
      • 22656
      • 121 Posts
      Ok, some further info.
      Snippet with above code is called "get_tags"
      I have one chunk on homepage which calls
      [[!getResourcesTag? &tvFilters=`tags==%[[!get_tags]]%`...

      this works fine and outputs the menutitle from the snippet.

      However, another chunk calls
      [[!getResources? &tvFilters=`tags==%[[!get_tags]]%`...

      but the snippet doesnt output anything here?

      what could be causing the problem? I used to just use
      [[*menutitle]]
      instead of get_tags snippet before, all this worked ok, however I had to tweak the output further hence the use of snippet instead of just a placeholder call.
        • 22656
        • 121 Posts
        lol, well i found a way.. its not pretty but it works:

        [[!get_tags? &strmenutitle=`[[*menutitle]]`]]


        so

        [[!getResourcesTag? &tvFilters=`tags==%[[!get_tags? &strmenutitle=`[[*menutitle]]`]]%`...


        then in get_tags I can access menutitle by referring to $strmenutitle
          • 3749
          • 24,544 Posts
          It's becauce documentObject is deprecated and no longer there.

          You want:

          $mt = $modx->resource->get('menutitle');




          ---------------------------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
          MODX info for everyone: http://bobsguides.com/modx.html
            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