Hi
New to php and modx and i’m trying to figure out how to do this: I want to be able to list siblings in a specified folder as small images. So far so good. I succeeded doing that by steeling shamelessly from other snippets (thank you whoever made "ContentListing"). Next I want to make sure that ONLY siblings appear in my imagemenu and NOT their children? Any suggestion?
And how do i make sure that the menu is sorted by menuindex.
Im stuck - please give me a hint...
The code looks like this:
// Usage:
// [[ContentListing?id=0]]
$content = "";
$root = $modx->getDocument($id , ’description’,’menuindex’);
$content .= $root[’pagetitle’]."";
if ($root[’description’]!="") {
// $content .= " - ".$root[’description’.’menuindex’];
}
$content .= "";
function getContent($id, $modx) {
$children = $modx->getActiveChildren($id,’pagetitle’,’ASC’,’id, pagetitle, description, isfolder, menuindex’);
$output = "<ul class=’bot’>\n";
foreach ($children as $child) {
if($child[’id’]==$modx->documentIdentifier) {
$active="img src=’thumbs/firkant.gif’ border=’0’";
} else {
$active="img src=’thumbs/firkantHover.gif’ border=’0’";
}
if ($child[’isfolder’]==0) { //Følgende opgave hvis der er tale om et dokument
$output .= "<li class=’botli’>";
$output .= "<a href=’index.php?id=".$child[’id’]."’><".$active.">".$child[’’]."</a>";
if ($child[’description’]!="") {
$output .= "".$child[’’];
}
$output .="</li>\n";
} else { //Følgende opgave, hvis der er tale om en mappe
$output .= "<li class=’botlito’>";
$output .= "<a href=’index.php?id=".$child[’id’]."’><img src=’thumbs/firkant.gif’border=’0’>".$child[’’]."</a>";
if ($child[’description’]!="") {
$output .= " - ".$child[’’];
}
$output .= "</li>\n";
$output .= getContent($child[’id’], $modx);
}
}
$output .= "</ul>";
$sortBy = ’menuindex’;
return $output;
}
$content .= getContent($id, $modx);
return $content; //udskriv