We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38740
    • 45 Posts
    Hi,
    like to change the content of a resource programatically. Is there a "setResourceField" ?

    What is the best way?

    Thx! [ed. note: johnjohn22 last edited this post 14 years, 4 months ago.]
      ____________________________________________________
      • 4172
      • 5,888 Posts
      if ($resource = $modx->getObject('modResource',$resid)){
          $resource->setContent('new Content');
          if ($resource->save()){
              $output = 'Resource '.$resource->get('pagetitle').' saved';
          }
          else{
              $output = 'There was an error saving Resource '.$resource->get('pagetitle');
          }
      }
      else{
          $output = 'Resource '.$resid.'not found';
      }
      
      return $output;
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 38740
        • 45 Posts
        Thanks Bruno17, works like a charm!
          ____________________________________________________