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

    i try to add a new tv to some of my resources to categorize them. My tv is a select box with single select option. In the front-end I use getResources-Snippet to get all resources with the same category as the selected resource.

    So i need literally hundrets of resources to save the new standard value. Do I need a script for that or did i misconfigure my tv?

    It's configured like so (i translated it from german so it's propably not exactly what the labels are in manager):

    Input Options
    Lustiges & Skurriles ||
    Sprüche & Zitate ||
    Videos ||
    Comics 
    


    Standard value
    Lustiges & Skurriles


    Allow empty input
    false


    activate Autocomplete
    false


    autocomplete delay
    250


    limit selection to list
    true


    all the other options are empty.
      • 11055 ☆ A M B ☆
      • 3,112 Posts
      create a PHP file, put it along side of index.php

      <?php
      define('MODX_API_MODE', true);
      require 'index.php'; // this goes to main index.php
      
      $c = $modx->newQuery('modResource');
      
      // in case you need a condition, change this accordingly
      // $c->where(array(
      // 	'parent' => 1
      // ));
      
      $resources = $modx->getCollection('modResource', $c);
      if (!$resources) {
      	die('crap!');
      }
      
      $putTVValueHere = 'foo';
      foreach ($resources as $resource) {
      	$resource->setTVValue('yourTVname', $putTVValueHere);
      }
      
      die('Finish');
      
        Rico
        Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
        MODx is great, but knowing how to use it well makes it perfect!

        www.virtudraft.com

        Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets

        Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

        Maintainter/contributor of Babel

        Because it's hard to follow all topics on the forum, PING ME ON TWITTER @_goldsky if you need my help.