Trying to make a mega menu witht he custom menu. I've got strange things happening in the way that divs are opened and closed. What I'm trying to do is at http://shanejeffers.com/blog/megadrop-mega-drop-down-menu-css-framework
I've set up the following renderer (please ignore the commented out bits - I've been slashing away at this)
* Renders a custom menu node as part of a submenu
*
* @see render_custom_menu()
*
* @staticvar int $submenucount
* @param custom_menu_item $menunode
* @return string
*/
protected function render_custom_menu_item(custom_menu_item $menunode) {
// Required to ensure we get unique trackable id's
static $submenucount = 0;
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$submenucount++;
//this only fires when submenu present
// echo $menunode->get_title();
//if array($menunode->get_title()=="column") {
//print ('Nothing');
//}
$content .= "<li>";
$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
$content .= "<div class='container-4'><div class='col2'>";
//$content .= html_writer::start_tag('div',array('class'=>'col2'));
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_'.$submenucount;
}
//echo $menunode->get_text();
//$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
//$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
// $content .=" <div class=\"col2\">";
//$content .= html_writer::start_tag('div',array('class'=>'container-4'));
foreach ($menunode->get_children() as $menunode) {
if ($menunode->get_text() == "columnStart") {
$content .=" <div class=\"col2\">";
}
elseif ($menunode->get_text() == "columnEnd") {
$content .="</div>fred";
}
else {
$content .= $this->render_custom_menu_item($menunode);
}
}
$content .= html_writer::end_tag('li');
//$content .= html_writer::end_tag('div');
} else {
// The node doesn't have children so produce a final menuitem
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
$content .= html_writer::end_tag('li');
}
// Return the sub menu
return $content;
}
and it produced this HTML
<ul id="yui_3_13_0_2_1402197781732_13" class="nav clearfix"><li id="yui_3_13_0_2_1402197781732_12"><a id="yui_3_13_0_2_1402197781732_11" title="Current Students" href="http://127.0.0.1/">Current Students</a></li><li><a title="Centres of Excellence">Centres of Excellence</a><div class="container-4"><div class="col2"></div></div></li><li><a title="Moodle free support" href="https://moodle.org/support">Moodle free support</a></li><li><a title="Moodle development" href="https://moodle.org/development">Moodle development</a></li> <div class="col2"><li><a title="Moodle Docs" href="http://docs.moodle.org">Moodle Docs</a></li></div>fred<li><a title="Resources" href="http://127.0.0.1/">Resources</a></li><li><a title="Library" href="http://127.0.0.1/">Library</a></li><li><a title="Contact Us" href="http://127.0.0.1/">Contact Us</a></li></ul>
If you look, you can see that as soon as the divs 'container-4' and 'col2' are opened, they're shut again. Where are the closing div tags coming from???
Many thanks for any help.
Gary