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

    i changed the isfolder field in the site_content table from Database and not from inside modx because i don´t want do update every field manualy. But now i saw that the URI Field for SEO Friendly Urls are only updated if i change the alias field and save the Resource. Is there a function to write global the URI new for every Resource? If i need to do this for over 200 resources it needs much to long.

    Thx
      • 3749
      • 24,544 Posts
      I think you could do it with a snippet. Something like this:


      $resources = $modx->getCollection('modResource');
      
      foreach ($resources as $resource) {
      
         $alias = $resource->get('alias');
         $uri =  // whatever you want;
         $resource->set('uri', $uri);
         $resource->set('uri_override', 1);
         $resource->save();
      
      }
      


      I would try it with a single resource first, using

      $resource = $modx->getObject('modResource', array('pagetitle' => 'TestPage')) 


      instead of getCollection() until you’re sure it works.
        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
        • 22303 MODX Staff
        • 10,725 Posts
        If you change the isfolder field via the API and save() the Resource, it will automatically updates all the child Resources if any data changes what the calculated URI would be.
          • 6059
          • 45 Posts
          Thanks for your help the URIs are now updated