
<?php

if ($marking == 'top')
{
    ?>


    <table class="table_menu_top" cellspacing="0" cellpadding="0" width="100%">
        <tr>

            <?php
            foreach ($menu as $title => $route)
            {

                $link = url_for($route);

                if ($route != '@homepage')
                {
                    $class = "";
                    if (strpos($path, '/product/') !== false)
                    {
                        $path = '/catalog/';
                    }
                    if (strpos($path, $link) !== false)
                    {
                        $class = "menu_top_link__active";
                    }
                }
                else
                {
                    $class = "";
                    if ($path == '/')
                    {
                        $class = "menu_top_link__active";
                    }

                }

                ?>

                <td align="center">
                    <nobr>
                        <a href="<?php echo $link ?>" class="menu_top_link <?php echo $class ?>"><?php echo $title ?></a>
                    </nobr>
                </td>

                <?php
            }

            foreach ($pagesFromDb as $page)
            {

                $link = url_for('@show_page?alias=' . $page->getFolder());
                $title = $page->getTitle();
                $class = "";

                if ($path == $link)
                {
                    $class = "menu_top_link__active";
                }

                ?>

                <td align="center">
                    <nobr>
                        <a href="<?php echo $link ?>" class="menu_top_link <?php echo $class ?>"><?php echo $title ?></a>
                    </nobr>
                </td>

                <?php

            }

            ?>

            <td align="center">
                <nobr>
                    <a href="tel:83472296013" class="menu_top_link">8 (347) 229-60-13</a>
                </nobr>
            </td>

        </tr>
    </table>

    <?php
}
elseif ($marking == 'bottom')
{

    ?>


    <ul class="er_footer_menu">


        <?php

        foreach ($menu as $title => $route)
        {
            $link = url_for($route);

            echo '<li><a href="' . $link . '">' . $title . '</a></li>';

        }

        foreach ($pagesFromDb as $page)
        {

            $link = url_for('@show_page?alias=' . $page->getFolder());
            $title = $page->getTitle();

            echo '<li><a href="' . $link . '">' . $title . '</a></li>';

        }

        ?>

    </ul>


    <?php

}
elseif ($marking == 'page404')
{

    ?>



    <ul class="page404_nav">
        <li><a href="/">Главная</a></li>
        <?php

        foreach ($pagesFromDb as $page)
        {

            $link = url_for('@show_page?alias=' . $page->getFolder());
            $title = $page->getTitle();

            echo '<li><a href="' . $link . '">' . $title . '</a></li>';

        }

        ?>
    </ul>

    <?php

}
?>
