<?php
$results = $modx-> getDocumentChildren (
$id = 0,
$active = 1,
$deleted = 0,
'id, pagetitle, published, menuindex, deleted, hidemenu, menutitle',
$where = 'hidemenu = 0',
$sort='menuindex',
$dir='ASC',
$limit
);
$cid = $modx->documentIdentifier;
$items = "";
$output = "";
foreach($results as $key => $value) {
if ($value["id"] == $cid) {
$active = " class=\"navactive\"";
}
else {
$active = "";
}
$items .= "<li>
<a href=\"[~".$value["id"]."~]\" ".$active." title=\"".$value["pagetitle"]."\">".$value["pagetitle"]."
</a></li> \n";
}
if ($items != "") {
$output = "<ul>\n";
$output .= $items;
$output .= "</ul>\n";
}
return $output;
?><ul> <li><a href="index" class="navactive" title="Главная">Главная</a></li> <li><a href="about" title="О проекте">О проекте</a></li> <li><a href="works" title="Галерея">Галерея</a></li> <li><a href="services" title="Работы">Работы</a></li> <li><a href="blog" title="Блог">Блог</a></li> <li><a href="contacts" title="Контакты">Контакты</a></li> </ul>
<ul> <li><a href="index" class="navactive" title="Главная">Главная</a></li> <li><a href="about" title="О проекте">О проекте</a></li> </ul> <ul> <li><a href="works" title="Галерея">Галерея</a></li> <li><a href="services" title="Работы">Работы</a></li> </ul> <ul> <li><a href="blog" title="Блог">Блог</a></li> <li><a href="contact" title="Контакты">Контакт</a></li> </ul>
This question has been answered by kp52. See the first response.
<?php
$results = $modx-> getDocumentChildren (
$id = 0,
$active = 1,
$deleted = 0,
'id, pagetitle, published, menuindex, deleted, hidemenu, menutitle',
$where = 'hidemenu = 0',
$sort='menuindex',
$dir='ASC',
$limit
);
$cid = $modx->documentIdentifier;
$items = array(); ////// внимание! //////
$output = "";
foreach($results as $key => $value) {
if ($value["id"] == $cid) {
$active = " class=\"navactive\"";
}
else {
$active = "";
}
////// внимание! //////
$items[] = "<li>
<a href=\"[~".$value["id"]."~]\" ".$active." title=\"".$value["pagetitle"]."\">".$value["pagetitle"]."
</a></li> \n";
}
$output = "";
while ($nextItem = array_shift($items)) {
$output .= "<ul>\n";
$output .= $nextItem;
$output .= array_shift($items);
$output .= "</ul>\n";
}
return $output;
?><li><a href="[~[+id+]~]" [+active+] title="[+pagetitle+]">[+pagetitle+]</a></li>
foreach($results as $key => $value) {
if ($value["id"] == $cid) {
$value['active'] = " class=\"navactive\"";
}
else {
$value['active'] = "";
}
$items[] = $modx->parseChunk('menuItem', $value, '[+', '+]');
}

