$base_path = MODX_CORE_PATH . 'components/mycmp/';
$modx->addPackage('mycmp',$base_path.'model/','');
$things = $modx->getCollection('Things',array());
$output = '';
$x = new modElement();
$tpl = '
<tr>
<td>[[+thing_id]]</td>
<td>[[+name]]</td>
<td>[[+etc]]</td>
</tr>
';
foreach ($things as $t)
{
$output = $x->process( $t->toArray(), $tpl);
}
return $output;Fatal error: Call to a member function getPackage() on a non-object in /path/to/revo/core/xpdo/om/xpdoobject.class.php on line 598
$x = $modx->newObject('modChunk');
$tpl = '
<tr>
<td>[[+thing_id]]</td>
<td>[[+name]]</td>
</tr>
';
foreach ($things as $t)
{
$x->setCacheable(false);
$output .= $x->process( $t->toArray(), $tpl);
}
return $output;$tpl = '
<tr>
<td>[[+thing_id]]</td>
<td>[[+name]]</td>
</tr>
';
foreach ($things as $t){
$x = $modx->newObject('modChunk');
$x->setCacheable(false);
$x->setContent($tpl);
$output .= $x->process( $t->toArray());
}
return $output;
foreach ($thing as $t)
{
$x = $modx->newObject('modChunk');
$x->setCacheable(false);
$x->setContent($tpl);
$output .= $x->process( $t->toArray() );
}
Any idea how to force MODx to clean up the unused placeholders? I’m ending up with more than a few [[+of_these]] in my output.
foreach ($thing as $t)
{
$x = $modx->newObject('modChunk');
$x->setCacheable(false);
$x->setContent($tpl);
$output .= $x->process( $t->toArray() );
}
$prefix = preg_quote('[[');
$suffix = preg_quote(']]');
$regex = '/' . $prefix . '\+[^' . $prefix . $suffix . ']+' . $suffix . '/';
if($result = preg_replace($regex ,'',$output))
{
$output = $result;
}
$regex = '/' . $prefix . '\+[a-zA-Z0-9_]+' . $suffix . '/';
