One other thing's bugging me. I can't seem to get anything in the else block to execute. currently, I have the following:
$input = MODX_ASSETS_PATH . "files/" . $cover;
if (is_readable($input)) {
$thumb = $modx->runSnippet('phpthumbof', array(
'input' => $input,
'options' => 'w=600&h=450&zc=1')
);
}
else {
$thumb = MODX_ASSETS_PATH . "img/cover-image-not-available.gif";
}
It doesn't matter what I put in the else statement - be it an echo command etc - it never runs, even when there's no cover image set.
Here's the full code, in case I'm missing something else:
function outputList($a,$b,$format){
global $modx;
// PAST PROJECTS FROM HERE
echo '<div id="past-projects"><h2>Past<br/>Projects</h2><ul>';
foreach ($a as $p) { // Loop through projects
$id = $p['id']; // Get project ID
foreach ($b as $t) { // Iterate over TVs
if ($t['contentid'] == $id) { // Reduce selection to relevent
switch ($t['tmplvarid']) {
case 3:
$cover = $t['value'];
break;
case 5:
$start = formatDate($t['value']);
break;
case 6:
$end = formatDate($t['value']);
break;
}
}
}
$input = MODX_ASSETS_PATH . "files/" . $cover;
if (is_readable($input)) { // Check a cover photo was actually selected
$thumb = $modx->runSnippet('phpthumbof', array(
'input' => $input,
'options' => 'w=600&h=450&zc=1')
);
}
else {
$thumb = MODX_ASSETS_PATH . "img/cover-image-not-available.gif";
}
echo $modx->getChunk('Past-Projects-Tpl',array(
'name' => $p['pagetitle'],
'url' => $p['uri'],
'start' => $start,
'end' => $end,
'content' => $p['content'],
'imgsrc' => $thumb)
);
$cover = null;
$start = null;
$end = null;
};
echo '</ul>';
};