<?php
/**
 * Copyright © 2015 Solwin Infotech. All rights reserved.
 */
?>
<?php
/**
 * Top Navigation menu for website
 *
 * \Solwin\Megamenu\Block\Topmenu
 */
?>
<?php
$_helper = $this->helper('Solwin\Megamenu\Helper\Data');
$_config = $_helper->getConfig('megamenu');

$columnsLimit = 0;
$vmenu_helper = $this->helper('Solwin\Verticalmenu\Helper\Data');
$enable_vmenu = $vmenu_helper->getEnableModule();
$menu_static_block = 'custom-home-menu';

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
$base_url = $storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);

if ($_config['general']['enable']) {
    ?>
    <?php $_menu = $block->getMegamenuHtml(); ?>
    <div class="page-main nav-outer">
        <nav class="navigation <?php if ($enable_vmenu) { ?> envm <?php } ?> sol-megamenu" role="navigation">
            <ul>
                <?php //echo $_menu; ?>
		<li class="level0 ui-menu-item active"><a href="<?php echo $base_url;?>" class="level-top"><span>Home</span></a></li>
		<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId($menu_static_block)->toHtml(); ?>
            </ul>
        </nav>
    </div>
    <script type="text/javascript">
        require([
            'jquery',
            'Solwin_Megamenu/js/megamenu'
        ], function ($) {
            $(".sol-megamenu").solMegamenu({
            });
        });
    </script>
    <?php
} else {
    ?>
    <?php $_menu = $block->getHtml('level-top', 'submenu', $columnsLimit); ?>
    <div class="page-main nav-outer">
        <nav class="navigation sol-megamenu" role="navigation">
            <ul data-mage-init='{"menu":{"responsive":true, "expanded":true, "position":{"my":"right top","at":"right bottom"}}}'>
                <?php /* @escapeNotVerified */ echo $_menu; ?>
            </ul>
        </nav>
    </div>
    <?php
}
?>