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
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 |
|
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.htmlThanks!
This task depends upon
This task blocks these from closing
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;
}
Dimmy