We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33992 ☆ A M B ☆
    • 455 Posts
    Hello friend, you had reported this bug here and added WHERE statement.
    I replied you correction and completed WHERE here and updated zip file.

    Thank you for your notice....
      God loves me. 【ツ】


      MODX.ir (Persian Support)

      Boplo.ir/modx/ (Persian)
      • 18190
      • 5 Posts
      Damned !
      I’m schizophrenic !
        • 7455
        • 2,204 Posts
        Hello AHHP,

        I wonder if you could extent the getDocField function in a way that it parses the elements in the fields? like snippets and chunks.

        I am working on a pdf writer that generates a pdf from a document, so I like to get the parsed content like getDocumentOutput but then for each field seperate.

        that would be great.

        Dimmy
          follow me on twitter: @dimmy01
          • 33992 ☆ A M B ☆
          • 455 Posts
          Hello Dimmy,
          Unfortunately Evolution has no solution to parse tag unless we create a parser like MODx’s.
          And the getDocumentOutput does not parse by itself but it use MODx index.php as a normal document request.
          There is possible to do some especial actions to do that (like create a blank document, put element tag in it, send request, get output as element output and delete document that does not seem good)
          Do you have any idea?


          About PDF project, about all PDF creators does not support unicode and Persian languages, just TCPDF.
          PLEASE do not forget Unicode languages!


          Thanks
          AHHP
            God loves me. 【ツ】


            MODX.ir (Persian Support)

            Boplo.ir/modx/ (Persian)
            • 7455
            • 2,204 Posts
            Could we not use a part of the getTemplateVarOutput method?
            http://wiki.modxcms.com/index.php/API:getTemplateVarOutput
            looks like there is a way to render tv so it renders the output?
            or is this only the inclusion of the widget?


            for pdf I was using fpdi because we can use templates(read reday made pdf files to fill) for that and fpdi is using tcpdf so I thing that that ok?

            Dimmy
              follow me on twitter: @dimmy01
              • 33992 ☆ A M B ☆
              • 455 Posts
              getTemplateVarOutput just create widgets (getTVDisplayFormat does that).

              And about fpdi, please read my PM.


              Regards,
              AHHP
                God loves me. 【ツ】


                MODX.ir (Persian Support)

                Boplo.ir/modx/ (Persian)
                • 36805
                • 354 Posts
                Thanks for this plugin, it helped me write a plugin to set/unset a document group depending on a radio button TV.

                NOTE: I experienced a caveat with including the CakeMODx class in a plugin. Turns out you cannot include CakeMODx.class.php or you will get a MODx parser error. Rename it to CakeMODx.php and update your include and it will go away.

                For my plugin see this topic.
                  • 36805
                  • 354 Posts
                  I noticed MODx (Evo) does not create a record for the tv value if it is empty for a document (or default is kept). Only if you change it to something, it will create it. As soon as you clear its content, it will delete the record again. (I think this is not documented anywhere huh)

                  Now this is a bummer. I want to preprocess some tv values and the content field and store result in another tv. So later I can output this efficiently in a Ditto placeholder.

                  At first it was working perfectly by using updateTV. Until I noticed this behaviour for empty/defaultvalue TVs. The first time i need to type some bogus into the tv manually just to get the record in there and be able to call $cake->updateTV(..) on it.

                  Problem summary: The CakeModX api function updateTV will only update existing records. The function setTV will add an entirely new tv not insert a new value record (better call it addTV). Does anyone have a workaround for this?
                    • 36805
                    • 354 Posts
                    To solve the problem described above, I’ve coded a function which checks if a TV content record is present. If it’s not present, it automatically creates it and fills it with a dummy value (default is a space).

                    Use this if you really need to be sure that your value will be in there after calling updateTV.

                    I’ve extended the CakeMODx class so this can be used easily without touching the existing code.

                    <?php
                    
                    include_once('CakeMODx.php');
                    
                    class MyCake extends CakeMODx
                    {
                    
                        /**
                         * Makes sure that a content record is present for this TV
                         * Inserts this record if not present     
                         *
                         * @param mixed $tv Name of ID of TV. It recognizes NUMERIC inputs as ID so Be careful with Numeric names!
                         * @param integer $docId ID of document.
                         * @param string $init initialization value of new TVs.
                         * @return mixed New TV contentvalue row on success and FALSE or 0 on failure.
                         */
                      public function ensureTV($tv, $docId, $init = null)
                      {
                      		if( !is_numeric($tv) )
                      		{
                      			$arr = $this->TV_name2id(array($tv));
                      			$tv = (integer) $arr[$tv];
                      		}
                      		
                      		if( !is_numeric($tv) || $tv == 0 )
                      			return false;
                      			
                      	  if ($init === null)
                      	   $init = ' ';  	  
                      		
                      		$fields = array("tmplvarid" => $tv, 'contentid' => $docId, 'value' => $value);
                      		
                      		$res = $this->db->select('id', $this->getFullTableName('site_tmplvar_contentvalues'), "tmplvarid=$tv AND contentid = $docId");
                      		if($this->db->getRecordCount($res) > 0)
                      			return true;             
                    
                          $this->db->insert($fields, $this->getFullTableName('site_tmplvar_contentvalues'));
                            return $this->db->getInsertId();
                      }
                    
                    }
                    
                    ?>