Hi all,
Using evo 1.02, on a windows xp machine running wamp with php 5.3.0 and mysql 5.1.36.
I want to use a combination of two tv’s to override the db entries of the doc_groups table. This because I want to use the new ajaxSearch function to filter on TV’s. I wrote the following plugin:
global $modx;
$table_docgroup = $modx->getFullTableName("document_groups");
$table_groupname = $modx->getFullTableName("documentgroup_names");
$tvpubliek = $modx->getTemplateVarOutput("publiek", "61", "1"); //get publiek
$publiek = $tvpubliek[publiek];
//if value != public we need a value in db
if($publiek != "Publiek") {
$tvgroup = $modx->getTemplateVarOutput("documentcategorie", "61", "1"); //get value of documentcategorie
$groupname = $tvgroup[documentcategorie]; //get the value out of the array
$groupid=$modx->db->getValue($modx->db->select("id", $table_groupname, "name= '". $groupname . "'")); //get groupid
$query = "INSERT INTO " . $table_docgroup . " (document_group, document) VALUES (" . $groupid . ", 61)"; //query to insert new value
$modx->db->delete($table_docgroup, "document=61"); //first delete all entrys for this id, since it's possible they changed
$modx->db->query($query); //insert values in db
}
else {
$modx->db->delete($table_docgroup, "document=61"); //first delete all entrys for this id, since it's possible they changed
}
This works fine, except for the fact that when I replace the 61 value with $modx->documentIdentifier, I get an error which points to an empty value for $modx->documentIdentifier.
I think this might be because I run the plugin on the OnDocFormSave event. Perhaps there is no docid at that event? Does someone know a way to do it after it was saved? Or did I miss the way to get the id of the document I am saving?
Thanks in advance,