Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

Get the title of a module via twig

Started by Muut Archive 11 years ago · 3 replies · 442 views
11 years ago

Hello all,

I want to give a specific Image the title from a module forthe link hash and give the navigation items the right name. In my navigation i looped through my page.collection()and got the name for every module. So how can I get the title and not the module name and get the first module title for my image?

---twig
<header class="header">
<div id="logo" class="blend webkit-fix">
<a href="#{{ self.1 }}">
<img src="{{ url('theme://img/logo.svg') }}" alt="PROMEDIAGROUP" title="PROMEDIAGROUP" class="webkit-fix">
</a>
</div>
<nav class="nav webkit-fix">
{% macro pageLinkName(text) %},{{ text|lower|replace({' ':'
'}) }},{% endmacro %}
{% for row in page.collection()|batch(2) %}
<ul>
{% for key, module in row %}
<li>
<a href="#{{ _self.pageLinkName(module.menu) }}" data-number="{{ key }}">{{ module }}</a>
</li>
{% endfor %}
</ul>
{% endfor %}
</nav> <!-- primary-nav -->
<div class="nav-trigger webkit-fix"><span></span></div>
</header>

11 years ago

@muuvmuuv Does {{ module.title }} help you?

11 years ago

@Sommerregen nope it was a refresh bug in my browser. So module.menu is right

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1346 9 years ago
Archive · by Muut Archive, 9 years ago
2 933 9 years ago
Archive · by Muut Archive, 9 years ago
2 4060 9 years ago
Archive · by Muut Archive, 9 years ago
1 2945 9 years ago
Archive · by Muut Archive, 9 years ago
3 1117 9 years ago