<field name="template-menu" type="hidden" default='1' />
protected $defaults = array(
'template-menu' => '0',
'enable_current_id' => 0,
// ...
public function renderMenu(&$menu)
{
ob_start();
if (isset($this->args['template-menu']) && $this->args['template-menu'] == '1'): ?>
<div class="gf-menu-device-container responsive-type-<?php echo $this->args['responsive-menu']; ?>"></div>
<?php endif; ?>
<ul class="gf-menu <?php echo $this->args['class_sfx']; ?> l1"
<?php if (array_key_exists('tag_id', $this->args)): ?>id="<?php echo $this->args['tag_id']; ?>"<?php endif; ?>>
<?php foreach ($menu->getChildren() as $item) : ?>
<?php $this->renderItem($item, $menu); ?>
<?php endforeach; ?>
</ul>
<?php
return ob_get_clean();
}
public function renderMenu(&$menu)
{
ob_start();
$menuname = (isset($this->args['template-menu']) && $this->args['template-menu'] == '1') ? 'gf-menu gf-splitmenu' : 'menu';
?>
<?php // this if is probably wrong -> further tests required
if ($menu->getChildren()) : ?>
<?php if (isset($this->args['template-menu']) && $this->args['template-menu'] == '1'): ?>
<div class="gf-menu-device-container responsive-type-<?php echo $this->args['responsive-menu']; ?>"></div>
<?php endif;
// class_sfx is the class suffix, so it must be appended to the original class ?>
<ul class="<?php echo $menuname; ?><?php echo $this->args['class_sfx']; ?> l1"
<?php if (array_key_exists('tag_id', $this->args)): ?>id="<?php echo $this->args['tag_id']; ?>"<?php endif; ?>>
<?php foreach ($menu->getChildren() as $item) : ?>
<?php $this->renderItem($item, $menu); ?>
<?php endforeach; ?>
</ul>
<?php endif;
return ob_get_clean();
}
The following users have thanked you: Matt
public function renderMenu(&$menu)
{
ob_start();
$menuname = 'menu';
$sfxClass = isset($this->args['submenu-class_sfx']) ? $this->args['submenu-class_sfx'] : '';
if( $menu->getChildren() ) : // do not output anything if menu has no elements
// only if template menu is active, activate the top main layout and the responsive version
if( isset($this->args['template-menu']) && $this->args['template-menu'] == '1' &&
isset($this->args['style']) && $this->args['style'] == 'mainmenu'){
$menuname = 'gf-menu gf-splitmenu';
$sfxClass = isset($this->args['mainmenu-class_sfx']) ?
$this->args['mainmenu-class_sfx'] : '';
?><div class="gf-menu-device-container responsive-type-<?php
echo $this->args['responsive-menu'];?>"></div>
<?php
}
// class_sfx is the class suffix, so it must be appended to the original class ?>
<ul class="<?php echo $menuname; ?><?php echo $sfxClass; ?> l1"
<?php if (array_key_exists('tag_id', $this->args)):
?>id="<?php echo $this->args['tag_id']; ?>" <?php endif; ?>>
<?php foreach ($menu->getChildren() as $item) : ?>
<?php $this->renderItem($item, $menu); ?>
<?php endforeach; ?>
</ul>
<?php endif; // ( $menu->getChildren() )
return ob_get_clean();
}
Time to create page: 0.055 seconds