Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
startinggravity
/
menu--social-media.html.twig
Created
Oct 30, 2015
Star
1
Fork
0
Star
Code
Revisions
1
Stars
1
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Use a Drupal menu as a social media links block
Raw
menu--social-media.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{#
/**
* @file
* Theme override to display a social media links from a menu.
*
* Available variables:
* - menu_name: The machine name of the menu.
* - items: A nested list of menu items. Each menu item contains:
* - attributes: HTML attributes for the menu item.
* - below: The menu item child items.
* - title: The menu link title.
* - url: The menu link url, instance of \Drupal\Core\Url
* - localized_options: Menu link localized options.
*/
#}
{%
import
_self
as
menus
%}
{#
We call a macro which calls itself to render the full tree.
@see http://twig.sensiolabs.org/doc/tags/macro.html
#}
{{ menus.
menu_links
(
items
,
attributes
,
0
) }}
{%
macro
menu_links(
items
,
attributes
,
menu_level
) %}
{%
import
_self
as
menus
%}
{%
if
items
%}
<
ul
class
=
"
menu--social-media__links
"
>
{%
for
item
in
items
%}
<
li
{{
item
.
attributes
.
addClass
((
item
.
title
)
|
clean_class) }}>
<
a
href
=
"
{{
item
.
url
}}
"
title
=
"
{{
item
.
title
|
t }}
"
><
span
class
=
"
visually-hidden
"
>{{
item
.
title
}}</
span
></
a
>
</
li
>
{%
endfor
%}
</
ul
>
{%
endif
%}
{%
endmacro
%}
Sign up for free
to join this conversation on GitHub
. Already have an account?
Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.