We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2762
    • 1,198 Posts
    Nicola (Banzai) Reply #1, 20 years ago
    For a lot of sites I’m using this old NewsPublisher mod from luke.stokes and The Man Can!
    http://modxcms.com/forums/index.php/topic,824.0.html
    bug traker : http://modxcms.com/bugs/task/129

    works great with new Ditto 1.1 features

    but need an hack of document parser undecided
    // HACK **********************************************************
    // Insert this about line 1700 in document.parser.class.inc.php
    // right after function getTemplateVarOutput
    	#  Set template variable value
    	function setTV($tvname, $value, $docid="") {
    	   if($tvname== "") return false;
    		   if($docid == "") $docid = $this->documentIdentifier;
    		   //get id of tv
    		   $result=$this->db->select("id", $this->getFullTableName("site_tmplvars"), "name = '". $tvname . "'");
    		   if (!$result) return false;
    		   $row=$this->fetchRow($result);
    		   // query the db to see if there are any records to update
    		   $result=$this->db->select("Count(*) AS RecordsExist", $this->getFullTableName("site_tmplvar_contentvalues") , "tmplvarid=".$row['id']." AND contentid=".$docid);
    		   $row2=$this->fetchRow($result);
    		   if (!$row2['RecordsExist']) {
    				$fields = array(
    				"tmplvarid" => $row['id'],
    				"contentid" => $docid,
    				"value" => $value
    				);
    			   $rows_affected = $this->db->insert($fields, $this->getFullTableName("site_tmplvar_contentvalues"));
    		   } else {
    			   $rows_affected = $this->db->update("value='" . $value . "'", $this->getFullTableName("site_tmplvar_contentvalues") , "tmplvarid=".$row['id']." AND contentid=".$docid);
    		   }
    		   return $rows_affected;
    	}
    // END HACK **********************************************************


    why don’t add it in new releas?


    edit: original luke.stokes’s NP mod uses an old version of NewsPublisher I have updated it with NP 1.4 attached to this post
      Free MODx Graphic resources and Templates www.tattoocms.it
      -----------------------------------------------------

      MODx IT  www.modx.it
      -----------------------------------------------------

      bubuna.com - Web & Multimedia Design
      • 22303 MODX Staff
      • 10,725 Posts
      Why can’t the function be placed in a file for use by NewsPublisher? I don’t want to introduce temporary API’s that will be deprecated in the next release and there is no reason this function can’t be used within the NewsPublisher snippet without hacking any core files.
        • 2762
        • 1,198 Posts
        Nicola (Banzai) Reply #3, 20 years ago
        Quote from: OpenGeek at Sep 29, 2006, 12:17 AM

        Why can’t the function be placed in a file for use by NewsPublisher? I don’t want to introduce temporary API’s that will be deprecated in the next release and there is no reason this function can’t be used within the NewsPublisher snippet without hacking any core files.

        Sorry OpenGeek smiley I’m not a coder , do you think we can place the hack in a snippet or a php file (inside/snippet/newspublisher)?

        Should be a nice feature allow tv from newspublisher ...
          Free MODx Graphic resources and Templates www.tattoocms.it
          -----------------------------------------------------

          MODx IT  www.modx.it
          -----------------------------------------------------

          bubuna.com - Web & Multimedia Design
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: banzai at Sep 29, 2006, 05:39 AM

          Sorry OpenGeek smiley I’m not a coder , do you think we can place the hack in a snippet or a php file (inside/snippet/newspublisher)?
          Indeed we can; including it from an external file is fine or even defining the function directly in the snippet code would work.