We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37783
    • 85 Posts
    Hello.

    If I use MIGX I can set the value of any variable that I used with setTVValue.

    Please tell me if I use MIGXdb and I need to change the value of (publisehed = 0 | 1).

    How to do it correctly.

    I use this example

    http://rtfm.modx.com/display/ADDON/MIGXdb.Create+a+basic+gallery-management+from+scratch+with+MIGXdb


    [[!migx? &configs=`mygallery` &sortConfig=`[{"sortby":"pos","sortdir":"ASC"}]` &where=`{"published":"1"}`]]



    Array
    (
        [id] => 1
        [title] => 
        [description] => описание
        [resource_id] => 15
        [resource_ids] => 
        [image] => images/moto/S/01_Vespa_S_125_ie_College.jpg
        [extended] => 
        [pos] => 0
        [published] => 1
        [createdby] => 1
        [createdon] => 2012-10-25 14:19:52
        [editedby] => 0
        [editedon] => -1-11-30 00:00:00
        [deleted] => 0
        [deletedon] => -1-11-30 00:00:00
        [deletedby] => 0
        [publishedon] => 2012-10-26 11:28:07
        [publishedby] => 1
        [_alt] => 0
        [_first] => 1
        [_last] => 
        [idx] => 1
        [property.configs] => mygallery
        [property.start] => 0
    )
    Array
    (
        [id] => 2
        [title] => 
        [description] => 
        [resource_id] => 15
        [resource_ids] => 
        [image] => images/moto/S/S_red.jpg
        [extended] => 
        [pos] => 0
        [published] => 1
        [createdby] => 1
        [createdon] => 2012-10-25 14:20:22
        [editedby] => 0
        [editedon] => -1-11-30 00:00:00
        [deleted] => 0
        [deletedon] => -1-11-30 00:00:00
        [deletedby] => 0
        [publishedon] => 2012-10-25 14:20:22
        [publishedby] => 1
        [_alt] => 1
        [_first] => 
        [_last] => 
        [idx] => 2
        [property.configs] => mygallery
        [property.start] => 0
      • 4172
      • 5,888 Posts
      where do you want change the published value?
      from grid at manager?

      isn't there a context-menue with publish/unpublish (right-click into the grid)?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37783
        • 85 Posts
        no

        from the script code
          • 37783
          • 85 Posts
          Bruno Hello ))

          Can I use setTVValue() to change from custom snippet?

          in settings of migxdb i found custom classname form field, and in manual

          that


          Register the TVs for our processors (getlist,fields)
          
          We need to register TVs to include them in the getlist- and fields-processors.
          Todo so we need a new config-file under /core/components/migx/configs/
          
          with the same name as our MIGX-configuration: childstutorial.config.inc.php (should allready be installed with the MIGX-package)
          and this content:
          
          /core/components/migx/configs/childstutorial.config.inc.php
          1
          2
          3
          <?php
          $this->customconfigs['includeTVs'] = 1;
          $this->customconfigs['includeTVList'] = 'price,images,categories';
          


          cen i use
          myClassname->setTVValue("prise",$prise)

          in that case?
            • 4172
            • 5,888 Posts
            as soon as you have a field with name price in your formtabs and you have it in the includeTVList, the TV is automatically updated by the childresources-update-processor

            It is done in this part:

                    if ($includeTVs) {
                        $c = $modx->newQuery('modTemplateVar');
                        $collection = $modx->getCollection('modTemplateVar', $c);
                        foreach ($collection as $tv) {
                            $tvname = $tv->get('name');
                            if (isset($data[$tvname])) {
                                $data['tv' . $tv->get('id')] = $data[$tvname];
                                unset($data[$tvname]);
                            }
                        }
            
                        $data['tvs'] = 1;
                    }
            
            
                    if ($scriptProperties['object_id'] == 'new') {
                        //$object = $modx->newObject($classname);
                        if (!empty($parent)){
                            $data['parent'] = $parent;
                        }
                        $response = $modx->runProcessor('resource/create', $data);
                    } else {
                        //$object = $modx->getObject($classname, $scriptProperties['object_id']);
                        //if (empty($object)) return $modx->error->failure($modx->lexicon('quip.thread_err_nf'));
                        $response = $modx->runProcessor('resource/update', $data);
                    }
            
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 37783
              • 85 Posts


              I have one product with different colors (different number).

              Red 5 units, and blue 3.

              Let suppose that,a product with blue color is almost sold out and I have to change automatically the status of the publication of this color from my snippet, not from MIGX TV interfce in backend .

              I can rewrite the whole JSON array that contains all information MIGX TV with xPDO or can it be done differently?