We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37946
    • 70 Posts
    Everything seems to be set up correctly - I am able to get the resource Id's back from my error log, but when I execute the runSnippet, i get the "Call to a member function on a non-object" error.
    I'm not sure where I am going wrong. Any suggestions?

    Thank you!

    $resource = $modx->getObject('modResource',array(
            'published' => 1,
            'pagetitle' => $_GET['pagetitle']
        ));
          
        
        if ( $resource )
        {
            $pagetitle = $resource->get('pagetitle');
            $id = $resource->get('id');
            
            error_log( 'getting resource id: '.$id );
    
            $output = $modx->runSnippet('getResourceField', array(
                'id'         => $id,
                'isTV'       => 1,
                'processTV'  => 1,
                'field'      => 'productlogo'
            ));
            
            if ( $output != '' )
            {
                error_log( 'output: '.$output );
            }
        }
    
      • 9102 ☆ A M B ☆
      • 318 Posts
      I'm not sure what's going wrong with the snippet call, but it would be much more efficient to just get the TV directly like this:
      $tv = $modx->getObject('modTemplateVar',array('name'=>'productlogo'));
      $output = $tv->renderOutput($id);
      

      See Bob's excellent discussion of xPDO objects here: http://bobsguides.com/revolution-objects.html
        • 37946
        • 70 Posts
        Holy crap - that is brilliant! Thank you very much!!
          • 9102 ☆ A M B ☆
          • 318 Posts
          LOL, thank Bob, he's the one who published this method, I'm just the messenger ;-)