Login!
Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#129 — API for writing to TVs

Attached to Project — MODx
Opened by Brett (The Man Can!) - Tuesday, 22 November 2005, 10:29AM
Last edited by Ryan Thrash (rthrash) - Wednesday, 20 September 2006, 05:08PM
Task Type ToDo
Category Core Distribution
Status Researching
Assigned To Jason Coward (opengeek)
Operating System All
Severity Medium
Priority High
Reported Version 0.9.0
Due in Version 0.9.7
Due Date Undecided
Percent Complete 0%

Details

An API function to write to a TV would be great. Something like $modx->putTemplateVar. Forum thread here: http://modxcms.com/forums/index.php/topic,824.0.html

Thanks!
This task depends upon

This task blocks these from closing
Comment by Mark Kaplan (mark2005) - Wednesday, 08 February 2006, 10:42PM
Sounds great!

Comment by Brett (The Man Can!) - Thursday, 09 February 2006, 12:55AM
Hi Mark,
I'll post this to the forum too. Luke figured this out. Seems to work well. Feel free to use this or modify it. (Sorry for not posting it earlier. Moved on to a different project and totally forgot that we didn't give it back to the community.) We inserted this about line 1700, right after 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;
}

Comment by Dimitri Hilverda (Dimmy) - Friday, 13 April 2007, 04:18AM
Is there any progress on this isseu or do I need to make a core hack in all versions?

Dimmy

Comment by Jason Coward (opengeek) - Friday, 13 April 2007, 02:15PM
This functionality will be available as part of 0.9.7 release, via the new object-oriented API. Feel free to provide a custom function in your site to do this in the meantime; no core hacks should be required.