IDK what it could be, but perhaps if you shared the Snippet code I might be able to assist in diagnosing the problem.
Ok, this is weird... putting the Snippet on the page returns output... putting the same Snippet call on the page twice causes NO OUTPUT from either call.
I log the intended output... and only the first instance logs output to the logs (not to the screen). WTF?
<?php
/*------------------------------------------------------------------------------
INPUT:
type (str) -- for the type column in the database, e.g. job, job_centers
tpl (str) -- name of Chunk used for formatting the output of the Categories
Placeholders: category_id, parent_id, type, name, description, sort
OUTPUT:
maybe something intended for inclusion in a <select> option in a form
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
------------------------------------------------------------------------------*/
include_once(MODX_CORE_PATH.'config/edfconfig.inc.php');
if (empty($tpl) || empty($type))
{
$modx->log(modX::LOG_LEVEL_ERROR, "MISSING ARGS: getCategories Snippet requires &tpl and &type arguments.");
return '<!-- missing arguments -->';
}
$output = '';
$my_xpdo= new xPDO('mysql:host='.EDF_DB::$host.';dbname='.EDF_DB::$dbname, EDF_DB::$dbuser, EDF_DB::$dbpasswd,'');
$my_xpdo->addPackage(EDF_DB::$package_name,EDF_DB::$package_path);
/* http://rtfm.modx.com//display/xPDO20/Retrieving+Objects */
$query = $my_xpdo->newQuery('Categories');
$query->where(array(
'type' => $type,
));
$query->sortby('sort','ASC');
$resources = $my_xpdo->getCollection('Categories', $query );
// Stack the formatted output
foreach ($resources as $r) {
$resourceArray = $r->toArray();
$resourceArray['cls'] = $rowCls;
$output .= $modx->getChunk($tpl,$resourceArray);
}
unset($tpl);
unset($type);
unset($my_xpdo);
$modx->log(modX::LOG_LEVEL_ERROR, "getCategories Snippet ran: $output");
return $output;
?>
Fatal error: Cannot redeclare class
// Instantiate and store an instance of xPDO the first time the Snippet is called on a page
if ( !isset($modx->placeholders['edf_xpdo']) || !is_a( $modx->placeholders['edf_xpdo'], 'xPDO') )
{
$modx->placeholders['my_xpdo']= new xPDO('mysql:host='.EDF_DB::$host.';dbname='.EDF_DB::$dbname, EDF_DB::$dbuser, EDF_DB::$dbpasswd,'');
$modx->placeholders['my_xpdo']->addPackage(EDF_DB::$package_name,EDF_DB::$package_path);
}
require_once 'path/to/MyClassName.class.php';
// send the class instance to a modx placeholder if it hasn't been called already
if ( !isset($modx->placeholders['MyClassName']) )
{
$modx->placeholders['MyClassName']= new MyClassName;
}
// shorten the variable name, for convenience
$myClass = $modx->placeholders['MyClassName'];
$output = $myClass->myMethodName($parameters);
$output .= $myClass->myOtherMethodName($parameters);
return $output;