We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40735
    • 119 Posts
    I see. I've never written a MODX plugin before. Is the learning curve steep? Also, there are over 4100 resources already in this container. Is there an easy way to change all of those without doing each one manually?

    Thanks!
      • 3749
      • 24,544 Posts
      It depends on whether there is a fixed pattern for creating the uri from the existing alias or pagetitle. If there is, it's usually a pretty simple job for a snippet to set them all (and the same code could then be moved into the plugin).
        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
        • 4172
        • 5,888 Posts
        A snippet like that, could change all uris for you:

        <?php
        
        $parent = '9999999';
        $uri_path = 'news/';
        $c = $modx->newQuery('modResource');
        $c->where(array('parent'=>$parent));
        if ($collection = $modx->getIterator('modResource',$c)){
            foreach ($collection as $object){
                $object->set('uri',$uri_path. $object->get('alias'));
                $object->set('uri_override','1');
                $object->save();
            }
        }


        the plugin - code could look like that:

        <?php

        $parent = '9999999';
        $uri_path = 'news/';
        if ($resource->get('parent') == $parent) {
            $resource->set('uri', $uri_path . $resource->get('alias'));
            $resource->set('uri_override', '1');
            $resource->save();
        
        }
        



          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 40735
          • 119 Posts
          Thanks guys!