<nav class="mega-menu">
<ul>
<?php
/*
we grab all the data from our content region and assign it to a variable with a "skip-template" parameter set to "true". It will prevent from rendering the menu for now.
*/
$menu_custom = perch_content_custom('Mega Menu',array(
'skip-template' => true
), true);
// lets go through every menu item
foreach ($menu_custom as $key => $menuitem) {
// for every item that has a url defined we output a usual link for our navigation */
if(isset($menuitem['navitemhref'])){
echo "<li><a class='mega-menu-link' href='" . $menuitem['navitemhref'] . "'>" . $menuitem['navitem'] . "</a></li>";
} else {
// otherwise let's have a static label that will act as a drop down trigger
echo "<li class='mega-menu-dropdown'><span class='mega-menu-link'>" . $menuitem['navitem'] . "</span><div class='mega-menu-col-wrapper'>";
// now let's run a loop through all of Perch Blocks and identify whether there is a column or a column item that we are dealing with
foreach ($menuitem['_blocks'] as $key => $dropdownitem) {
if(isset($dropdownitem['collabel'])) {
// we also need to look out where column starts and finishes
if($key !== 0) {
echo "</ul></div><div class='mega-menu-col'><p class='mega-menu-link'>" . $dropdownitem['collabel'] . "</p>
<ul>";
} else {
echo "<div class='mega-menu-col'><p class='mega-menu-link'>" . $dropdownitem['collabel'] . "</p>
<ul>";
}
} else {
echo "<li class='mega-menu-item'><a href='" . $dropdownitem['colitemhref'] . "'>" . $dropdownitem['colitem'] . "</a></li>";
}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.