{*
 **********************************************************
 * Developed by: Team Theme Metro
 * Website: http://www.thememetro.com
 **********************************************************
*}

<!-- ******************************** mega-menu.tpl ******************************** -->
{foreach $navbar as $item}
{assign var='extras' value=$item->getExtras()}			
<li data-menuItemName="{$item->getName()}"{if $item->hasChildren()} class="dropdown {$extras['parentclass']}"{elseif $item->getClass()} class="{$item->getClass()}"{/if} {if $item->getName() eq 'Home'} style="display: none;"{/if}>
	<a class="nav-link{if !isset($rightDrop) || !$rightDrop}{/if}{if $item->hasChildren()} dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#"{else}" href="{$item->getUri()}"{/if}{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>

	{if $item->getName() == "Home"}<i class="fas fa-home"></i>{else}{if $item->hasIcon()}<i class="{$item->getIcon()}"></i>&nbsp;{/if}{/if}

	<!-- mega-menu.tpl -->
	<span>{$item->getLabel()}</span>

	{if $item->hasBadge()} <span class="badge">{$item->getBadge()}</span>{/if}

	</a>
{if $item->hasChildren()}
{assign var=haschild value=0}

	{if $extras['parentclass']=='dropdown-megamenu'}
	{assign var=haschild value=1}
	{/if}

<ul class="dropdown-menu{if $extras['parentclass']=='dropdown-megamenu'} dropdown-mega{/if}">
	
		{if $haschild}		
		<li>
		<div class="mega-menu">
			<div class="container">
				<div class="row">
		{/if}
				{assign var=count value=0}
				{assign var=totalchild value=count($item->getChildren())}				
				{foreach $item->getChildren() as $item}	
				{if $haschild}

				{assign var='extras' value=$item->getExtras()}
			<div class="menu-small-box {$extras['parentclass']}">
				{if $item->getUri()|strstr:"#"}
				<div class="item-with-icons">
					{if $item->hasIcon()}
					<span class="item-icon">
						<i class="{$item->getIcon()}"></i>
					</span>
				{/if}
				<h4 class="menu-name">{$item->getLabel()}</h4>
				</div>
				{else}						
				<a href="{$item->getUri()}"{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if} class="item-heading">
				<div class="item-with-icons no-margin">
					{if $item->hasIcon()}
						<span class="item-icon">
							<i class="{$item->getIcon()}"></i>
						</span>
					{/if}
					<h4 class="menu-name">{$item->getLabel()}</h4>
				</div>
				</a>
			{/if}
		{if $item->hasBadge()}
			<div class="html-item">{$item->getBadge()|unescape:'html'}</div>
		{/if}

		{if $item->hasChildren()}
			<ul class="menu-list">
				{foreach $item->getChildren() as $childItem}
				{assign var='extras' value=$childItem->getExtras()}
					<!-- mega-menu.tpl -->					
					<li data-menuItemName="{$childItem->getName()}"{if $childItem->getClass() || $extras['parentclass']} class="{$childItem->getClass()} {$extras['parentclass']}"{/if}>
						<a class="nav-link" href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
							{if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
							<span class="item">{$childItem->getLabel()|unescape:"html"}</span>
							{if $childItem->hasBadge()} 
								<span class="badge">
									{$childItem->getBadge()}
								</span>
							{/if}
						</a>
					</li>
				{/foreach}
			</ul>
		{/if}
	</div>					

	
	{else}
        {assign var='extras' value=$item->getExtras()}
        	{if $item->hasChildren()}
				<li class="mega-menu">        	
					<div class="menu-small-box {$extras['parentclass']}">
					{if $item->getUri()|strstr:"#"}
						<div class="item-with-icons">
							{if $item->hasIcon()}
							<span class="item-icon">
								<i class="{$item->getIcon()}"></i>
							</span>
							{/if}
							<h4 class="menu-name">{$item->getLabel()}</h4>
						</div>
					{else}						
						<a class="nav-link" href="{$item->getUri()}"{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if} class="item-heading">
							<div class="item-with-icons no-margin">
								{if $item->hasIcon()}
									<span class="item-icon">
										<i class="{$item->getIcon()}"></i>
									</span>
								{/if}
								<h4 class="menu-name">{$item->getLabel()}</h4>
							</div>
						</a>
					{/if}
					{if $item->hasBadge()}
						<div>{$item->getBadge()|unescape:'html'}</div>
					{/if}
					</div>
				</li>
				{if $item->hasChildren()}
					{foreach $item->getChildren() as $childItem}
					{assign var='extras' value=$childItem->getExtras()}
						
						<li data-menuItemName="{$childItem->getName()}"{if $childItem->getClass() || $extras['parentclass']} class="{$childItem->getClass()} {$extras['parentclass']}"{/if}>
							<a class="nav-link" href="{$childItem->getUri()}"{if $childItem->getAttribute('target')} target="{$childItem->getAttribute('target')}"{/if}>
								{if $childItem->hasIcon()}<i class="{$childItem->getIcon()}"></i> {/if}
								<span class="item">{$childItem->getLabel()}</span>
								{if $childItem->hasBadge()} 
									<span class="badge">
										{$childItem->getBadge()}
									</span>
								{/if}
							</a>
						</li>
					{/foreach}
				{/if}
			
        	{else}
	        	<li data-menuItemName="{$item->getName()}"{if $item->getClass() || $extras['parentclass']} class="{$item->getClass()} {$extras['parentclass']}"{/if}>
					<a class="nav-link" href="{$item->getUri()}"{if $item->getAttribute('target')} target="{$item->getAttribute('target')}"{/if}>
						{if $item->hasIcon()}<i class="{$item->getIcon()}"></i> {/if}
						<span class="item">{$item->getLabel()}</span>
						{if $item->hasBadge()} 
							<span class="badge">
								{$item->getBadge()}
							</span>
						{/if}
					</a>
				</li>
        	{/if}
	        			
    {/if}
		{assign var=count value=$count+1}
{/foreach}
		{if $haschild}		
		</div>
	</div>
</div>
</li>
{/if}

</ul>
{/if}

</li>
{/foreach}

