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

    I'm updating some sites from Evo to Revo.

    There are some PHP 5.2 scripts written by myself to combine some data from different tables with MODX Evo documents.

    I used this to get the value of a Evo TV named bildKursdetail:
    $bild = $modx->getTemplateVarOutput(array("bildKursdetail"),$docid=$kurs_modx_id,$published=1);


    I tried with
    $bild = $modx->modTemplateVar->renderOutput(array("bildKursdetail"),$docid=$kurs_modx_id,$published=1);


    This doesn't work.

    To get an array of a resource's data from an doc id stored in $kurs_modx_id I used this code:
    $document=$modx->getDocument($kurs_modx_id);


    This does not work anymore. I tried:
    $document = $modx->getObject('modResource', array('id'=> $kurs_modx_id));


    but this did not work, as in the next step I had

    $alias=$document['alias'];


    This is now resulting in

    Fatal error: Cannot use object of type modDocument_mysql as array ... 


    I looked into the reference docs, but I'm not sure where to start ...

    I'm not into PHP too deep anymore, but I hope to be able to transfer the scripts to work with Revo.

    Can anyone give some hint on this?
    Thanks!

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      $tv = $modx->getObject('modTemplateVar', array('name' => 'bildKursdetail'));
      $bild = $tv->renderOutput($kurs_modx_id);  // rendered output
      $bild = $tv->getValue($kurs_modx_id);  // raw value


      If you happen to have the resource object already, either by getting it with getObject() or referencing $modx->resource, you can also do this

      $bild = $modx->resource->getTVValue('bildKursdetail');


      or

      $bild = $resource->getTVValue('bildKursdetail');


      Both of the above will get you the rendered TV output.

      This (below) should definitely work, though it's more complicated than necessary, since you have the Resource ID:

      $document = $modx->getObject('modResource', array('id'=> $kurs_modx_id));


      This should work also:

      $document = $modx->getObject('modResource', (int) $kurs_modx_id);


      Then,

      $alias=$document->get('alias');




        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
        • 36649
        • 77 Posts
        Hello Bob,

        thanks, your codes helped me a lot! Sorry for late reply, was in other project meantime.

        Best regards!
        Guenter