0

I make some field in theme setting and can use them normali in block, page, but when I want to use them in main menu its dont work.

function saka_theme_preprocess_menu__main (&$variables, $hook) {

    $variables['social_url_fb'] = theme_get_setting('social_url_fb','saka_theme');

}

and in menu--main.html.twig I write this..

{% for item in items %}
                <li {{ item.attributes }} >
                    <a  href="{{ item.url }}"  {{ item.attributes }} > {{ item.title }}</a>
                </li>
                <li>
                    <a href="{{ social_url_fb }}" class="btn-social-menu"><i class="fa fa-2x fa-facebook"></i></a>
                </li>
        {% endfor %}
2

You can't use name suggestions with double underscore in preprocess function names.

You have to replace this with an if statement in code:

function saka_theme_preprocess_menu(&$variables) {
  if ($variables['menu_name'] == 'main') {
    $variables['social_url_fb'] = theme_get_setting('social_url_fb','saka_theme');
  }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.