We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30023
    • 172 Posts
    I have the following code:

    			$wish_doc = new Document($row['id']);
    		(1)	$wish_qty = $wish_doc->Get('tvqty');
    		(2)	$wish_qty = reset($modx->getTemplateVarOutput('qty', $row['id']));
    			if ($order_qty >= $wish_qty) $wish_doc->Delete();
    			else $wish_doc->SetTV('qty', $wish_qty - $order_qty);
    


    AFAIK, (1) and (2) should do the same thing i.e. get the value of the ’qty’ Template Variable. However (2) works, but (1) doesn’t. What is wrong with (1) ??

    -- Tim.
      • 10449
      • 956 Posts
      That should work. I just did a quick test which works as expected:

      include_once('modxapi.php');
      require_once('document.class.inc.php');
      
      $modx = new MODxAPI();
      $modx->connect();
      $modx->getSettings();
      
      $list = array(30,31,32,28,40,47);
      
      foreach($list as $k=>$v) {
      
      	$doc = new Document($v);
      	$address = $doc->Get('tvhouseAddress');
      	echo $address . "<br />";
      
      } // end foreach
      
      
        • 30023
        • 172 Posts

        I agree that it should - but it doesn’t!!

        Clearly I have done something wrong somewhere, but what I don’t know. Not a big deal - I can just use getTemplateVarOutput, but am curious why there is a problem.

        -- Tim.
          • 30023
          • 172 Posts
          Finally found the problem while investigating another. My version of docmanager (0.5.3b which I believe is the latest stable release) has the following

          $this->oldTVs=$this->getTVValues();


          but getTVValues is nowhere to be found, hence it fails.