Created
          October 5, 2014 16:45 
        
      - 
      
- 
        Save christianseel/9ef49c1a2f225c337909 to your computer and use it in GitHub Desktop. 
    Replace ContentBlocks values with new values
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <? | |
| $c = $modx->newQuery('modResource'); | |
| $resources = $modx->getCollection('modResource', $c); | |
| foreach ($resources as $res) { | |
| $properties = $res->getProperties('contentblocks'); | |
| if (empty($properties)) continue; | |
| if (empty($properties['content'])) continue; | |
| $content = $properties['content']; | |
| $content = str_replace('"color":"blue"', '"color":"secondarytext"', $content); | |
| $content = str_replace('"color":"red"', '"color":"primarytext"', $content); | |
| $properties['content'] = $content; | |
| $res->setProperties($properties, 'contentblocks', true); | |
| $res->save(); | |
| echo $res->get('pagetitle')." REPLACED<br>"; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment