<html><head><title>Error 404: Page not found</title></head><body><h1>Page not found</h1><p>The page you
requested was not found.</p></body></html>
$resource = $modx->getObject('modResource', array ('id'=>$docid), true);
$output = $resource->process();<b>Fatal error</b>: Call to a member function get() on a non-object in <b>E:\xampp\htdocs\revolution
\core\components\wayfinder\wayfinder.class.php</b> on line <b>53</b>
'id' => $this->modx->resource->get('id'), $modx->resource = $modx->getObject('modResource', array ('id'=>$docid), true);
echo $modx->resource->process();}).send('reload=wrapper&docid='+brunoclass.doc_id+edited +'&docurl='+encodeURIComponent(document.URL));$modx->sendRedirect($_POST['docurl']);
getTemplateVars($TvnameIds=’*’, $fields = "*", $docid=’’, $template=’’, $published=’1’ , $sort = "rank", $dir = "ASC");
/*
*TvnameIds - TvNames or TvIds, ’*’ gets all:array
*$fields - Fieldnames, ’*’ gets all fields:array
*$docid - ResourceId, ’’ && $template == ’’ gets all TVs:string
*$template - TemplateId, ’’ && $docid == ’’ gets all TVs:string
*$published - 2 gets published and unpublished:string
*
*/
<?php
function getTemplateVars($Tvnames, $docid ){
global $modx;
$resourceId = $docid;
$resourceClass = 'modDocument';
$resource = $modx->getObject($resourceClass, $resourceId);
$docid = $resource->get('id') == $resourceId?$resourceId:'new';
if ($docid == 'new')
{
$tvObjects = $modx->getCollection('modTemplateVar');
$resourceFields = $modx->getFields($resourceClass);
} else
{
//$tvs = $modx->getTemplateVars($Tvnames, $fields = "*", $docid, $published , $sort = "rank", $dir = "ASC");
//$resourceClass= isset ($_REQUEST['class_key']) ? $_REQUEST['class_key'] : 'modDocument';
//see manager\controllers\resource\tvs.php
$tvObjects = $resource->getMany('modTemplateVar');
$resourceFields = $resource->toArray();
}
$tvs = array ();
if (is_array($tvObjects) && count($tvObjects) > 0)
{
foreach ($tvObjects as $tvObject)
{
$tv = $tvObject->toArray();
if (in_array($tv['name'], $Tvnames))
{
$tvs[$tv['name']] = $tv;
}
}
}
//merge documentfields to tvfields
foreach ($resourceFields as $key=>$field){
if (in_array($key,$Tvnames)){
$tvs[$key]['name'] = $key;
$tvs[$key]['value'] = $field;
}
}
/*
if (count($Tvnames) > 0)
{
foreach ($Tvnames as $Tvname)
{
$Tvname = trim($Tvname);
if ( isset($resourceFields[$Tvname]))
{
$tvs[$Tvname]['name'] = $Tvname;
$tvs[$Tvname]['value'] = $resourceFields[$Tvname];
}
}
}
*/
return $tvs;
}
?>
$tvCollection = $modx->getCollection('modTemplateVar', "`name` IN ('" . implode("','", array('footer', 'header', 'Test.One')) . "')");$resource = $modx->getObject('modResource', 12);
if ($resource) $tvCollection = $resource->getMany('modTemplateVar');
If you just want the TV’s irregardless of a specific Resource, you use the getCollection() method of xPDO, which the modX class extends:
$tvCollection = $modx->getCollection('modTemplateVar', "`name` IN ('" . implode("','", array('footer', 'header', 'Test.One')) . "')");
If you want all the TV’s and values specific to a Resource:
$resource = $modx->getObject('modResource', 12); if ($resource) $tvCollection = $resource->getMany('modTemplateVar');
Yes. $modx->getMany(’Alias’,$criteria);
Can I also have an criteria for "`name` IN (’" . implode("’,’", array(’footer’, ’header’, ’Test.One’)) . "’)" in getMany?
Another question to revo beta now: Is the new beta release the same as revision 5070?
$criteria = "`name` IN ('" . implode("','", $Tvnames) . "')";
$tvObjects = $resource->getMany('modTemplateVar',$criteria);
$resourceFields = $resource->toArray();
}
$tvs = array ();
if (is_array($tvObjects) && count($tvObjects) > 0)
{
foreach ($tvObjects as $tvObject)
{
$tv = $tvObject->toArray();
print_r($tv);
if (in_array($tv['name'], $Tvnames))
{
$tvs[$tv['name']] = $tv;
}
}
}