We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39117
    • 20 Posts
    Is there a way to delete a bunch of tv's (chunks etc.) at once?
    Thank you.
      • 4172
      • 5,888 Posts
      evo or revo?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 39117
        • 20 Posts
        Sorry, I forgot: Revo.
          • 38713
          • 91 Posts
          I imagine you can remove them straight from the DB under table modx_site_tmplvars. Pretty easy to navigate with phpMyAdmin etc.

          Check the ones you would like to delete and drop them.

          However don't do this before someone else confirming this or do a backup of the whole DB first then try it, anything goes wrong just drop the broken DB and re-import the original one.
            Twitter @alexmercenary
            • 4172
            • 5,888 Posts
            try this only when you know what you're doing and only at a unpublished resource or from manager.

            snippet:
            $classname = $modx->getOption('classname',$scriptProperties,'modTemplateVar');
            
            if (isset($_POST['removeElements'])){
                foreach ($_POST['row_id'] as $id){
                    $object = $modx->getObject($classname,$id);
                    $object->remove();
                }
            }
            
            $collection = $modx->getCollection($classname);
            
            foreach ($collection as $object){
                $fields = $object->toArray();
                $trs .= '<tr><td>'.$fields['name'].'</td><td><input type="checkbox" name="row_id[]" value="'.$fields['id'].'" /></td>'; 
            }
            
            $form = '<form method="post" action=""> <table>'.$trs.'</table><input type="submit" name="removeElements" /> </form>';
            
            return $form;
            


            example of snippet-call:

            [[!removeElements? &classname=`modChunk`]]

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

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 39117
              • 20 Posts
              Thanks. I will try.