Skip to content

Instantly share code, notes, and snippets.

@Dmi3yy
Created March 31, 2014 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dmi3yy/9887033 to your computer and use it in GitHub Desktop.
Save Dmi3yy/9887033 to your computer and use it in GitHub Desktop.
<?php
$core->event->params['TplMainOwner'] = '@CODE: <ul id="nav" class="menu level-1">[+dl.wrap+]</ul>';
$core->event->params['TplSubOwner'] = '@CODE: <ul class="sub-menu level-[+dl.currentDepth+]">[+dl.wrap+]</ul>';
$core->event->params['TplOneItem'] ='@CODE: <li id="menu-item-[+id+]" class="menu-item [+dl.class+]"><a href="[+url+]" title="[+e.title+]">[+title+]</a>[+dl.submenu+]</li>';
$core->event->params['addWhereList'] = 'c.hidemenu = 0';
$currentDepth = getkey($core->event->params, 'currentDepth', 1);
$currentTpl = getkey($core->event->params, 'TplDepth'.$currentDepth);
if(empty($currentTpl)){
$currentTpl = getkey($core->event->params, 'TplOneItem', '@CODE: <li>[+pagetitle+]</li>');
}
$currentOwnerTpl = getkey($core->event->params, 'TplOwner'.$currentDepth);
if(empty($currentOwnerTpl)){
$currentOwnerTpl = '@CODE: [+dl.wrap+]';
if($currentDepth==1){
$currentOwnerTpl = getkey($core->event->params, 'TplMainOwner', $currentOwnerTpl);
}else{
$currentOwnerTpl = getkey($core->event->params, 'TplSubOwner', $currentOwnerTpl);
}
}
return $core->runSnippet('DocLister', array_merge(array(
'orderBy' => 'menuindex ASC, id ASC'
), $core->event->params,array(
'idType' => 'parents',
'parents' => getkey($core->event->params, 'parents', 0),
'tpl' => $currentTpl,
'ownerTPL' => $currentOwnerTpl,
'prepare' => function($data, \Bolmer\Core $core, DocLister $_DL){
if($_DL->getCfgDef('currentDepth', 1) < $_DL->getCFGDef('maxDepth', 5)){
$core->event->params['currentDepth'] = $_DL->getCfgDef('currentDepth', 1)+1;
$core->event->params['parents'] = $data['id'];
$data['dl.submenu']=$core->runSnippet('BuildMenu', $core->event->params);
}else{
$data['dl.submenu'] = '';
}
$data['dl.currentDepth'] = $_DL->getCfgDef('currentDepth', 1);
$data['e.title'] = htmlentities($data['title'], ENT_COMPAT, 'UTF-8', false);
return $data;
}
))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment