Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Добрый день. Нужна Ваша помощь, мне надо сделать так что б горизонтальное меню на главной было скрыто, а на определенных станицах показывалось. Навоял тут небольшой код, но что-то пошло не так. помогите найти ошибку. Спасибо.


artemleon
 Share

Recommended Posts

Добрый день. Нужна Ваша помощь, мне надо сделать так что б горизонтальное меню на главной было скрыто, а на определенных станицах показывалось. Навоял тут небольшой код, но что-то пошло не так. помогите найти ошибку. Спасибо.

 

    <?php
    $path = "common/home";
    $url = $_SERVER['REQUEST_URI'];
    if ($url == "/" or strripos($url, $path)) {
    $is_home = TRUE;
    }else{
    $is_home = false;
    }

if ($url == "/") { ?>
 
 тут должно быть пусто
 
<?php } else if($url == "/about_page") { ?>

   {% if primary_menu %}
    <div class="table-cell text-center w60 menu-cell">
        <div class="main-menu">
            <ul class="categories">
              {% if primary_menu == 'oc' %}
                <!-- Default menu -->
                {{ default_menu }}
              {% elseif primary_menu is defined %} 
                <!-- Mega menu -->
                {% for key, row in primary_menu_desktop %}
                {% include 'basel/template/common/menus/mega_menu.twig' %}
                {% endfor %}
              {% endif %}
            </ul>
        </div>
    </div>
    {% endif %}

<?php } else { ?>
    <?php } ?>

Link to comment
Share on other sites


Или такой ваиант, что бы на главной использовался один файл с меню, а на другой тот который прописан в админке.

В изначальном коде прописано

{% include 'basel/template/common/headers/' ~ basel_header ~ '.twig' %}

В моем варианте:

  <?php
    $path = "common/home";
    $url = $_SERVER['REQUEST_URI'];
    if ($url == "/" or strripos($url, $path)) {
    $is_home = TRUE;
    }else{
    $is_home = false;
    }

if ($url == "http://amal.prettywoman.boutique/") { ?>
 
{% include 'basel/template/common/headers/header1.twig' %}

<?php } else if($url == "/about_page") { ?>


{% include 'basel/template/common/headers/' ~ basel_header ~ '.twig' %}

<?php } else { ?>
    <?php } ?>

 

Но по факту и на главной станице и на другой станице показываются оба

 

 

 

Link to comment
Share on other sites


Тут получается так, в идеале мне надо чтоб на главной странице сайта прогружался  файл header2.twig, a на всех других файл тот который выбран в админке сайта. С меню это полумера, она не очень подходит. И суть кода была такая, на главной меню не показывается, а на других присутствует. Но по факту у меня получилось что как на главной так и на других страницах показываются все что надо и не надо.

Link to comment
Share on other sites


Зачем вы в двух местах пишите?
Ваш код не работает, потому что в twig вообще невозможно исполнение php.
Перепишите его операторами twig

  • +1 1
Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.