We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34799
    • 2 Posts
    Hi, I am quite new to MODx but quite experienced about PHP.

    I am working on my new Snippets, but have no access to the TemplateVars from within my PHP Code. It works perfectly in HTML using [[*xxx]].

    My snippet looks like this:

    echo "\n".'$modx: '; print_r($modx);
    echo "\n".'documentObject: '; print_r($xxx=$modx->documentObject);
    echo "\n".'getTemplateVars('*'): '; print_r($modx->getTemplateVars('*'));


    documentObject is empty

    getTemplateVars(’*’) ==> Fatal error: Call to undefined method modX::getTemplateVars()

    Am I doing anything wrong? On this page http://rtfm.modx.com/display/MODx096/Document+Variables I read that it should work like this?

    I am using: MODX Revolution 2.1.3-pl (traditional) on localhost
    OS: Linux (ubuntu) Apache PHP 5.3.5 mysql, pdo_mysql installed
    Browser: Firefox
    I have caching disabled by: cache_scripts=no cache_resources=no
    How can I access those TVs from inside php?

    If I do print_r($modx) this Object does not contain any Field named "documentObject" sad.

    I searched the whole code of MODx for the word "documentObject" but could not find it.

    Before I sent this entry I thought that I read on. I found that something more did not work:

    echo "\n".’documentIdentifier: ’.$modx->documentIdentifier;

    Also Empty sad.

    What Am I doing wrong? I had planned to go on Vacation yesterday but can’t leve because this Project is not finished. Please HELP!

    NOTE: the only special Thing on my configuration is, that my MODx Files are not placed in document root. They are in some subfolder and look like Doc Root by useng mod_rewirte:

    RewriteCond %{HTTP_HOST}      ^www.xxx.at$
    RewriteCond %{REQUEST_URI}    !^/xxx/
    RewriteRule ^(.*)$            /xxx/www/$1 [L]
    


    I tried to configure the Server that it will not have to use this trick, but that did not change anything.

    Hannes

    For better analysis I wanted to post my $modx Variable (but I am limited to 3000 Character).
      What is this signature good for anyways?
      • 34193
      • 330 Posts
      getTemplateVars(’*’) is depreciated see http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1

      Use

      modX->getCollection(’modTemplateVar’, $criteria)

      EDIT : The docs obviously still need updating file a bug here http://bugs.modx.com/projects/docs
        • 34193
        • 330 Posts
        You may also find this page helpfull

        http://bobsguides.com/revolution-objects.html
          • 34799
          • 2 Posts
          FIRST: this is incredible, I was just reading through how to use placeholder in Chunks and as I finished, there was an answer already! Thank you.

          SECOND: Both links are very useful!
          Bobs Page is a valuable resource for 2.x API
          And the other Page is very useful if I read old documents and need some translation.

          Thank you again!

          PS.: I will not file a bug because it was my mistake, if you look at the Link I posted in Post, it says MODX096. Obviously there has been a lot of changes over the Time. As I step in now, I hope everything will stay the same for the next years ;-).
          PPS.: is there some way to mark this solved?
            What is this signature good for anyways?
            • 34193
            • 330 Posts
            AH yes just noticed you where looking at evo docs. Evo is still a valid route so they need to stay like that. You need to look at docs based around REVO. To mark as solved I think you need to edit initial post and add [SOLVED] to subject.