Add url based title to each exhibition
This commit is contained in:
parent
35351bc709
commit
2b79d762b3
2 changed files with 22 additions and 6 deletions
16
site/controllers/home.php
Normal file
16
site/controllers/home.php
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return function ($page) {
|
||||||
|
|
||||||
|
// Get exhibitions field content (stored as yaml) and parse it to return an array
|
||||||
|
$exhibitions = $page->exhibitions()->yaml();
|
||||||
|
|
||||||
|
// Add url based title to each exhibition
|
||||||
|
foreach ($exhibitions as &$exhibition) {
|
||||||
|
$exhibition['title'] = str_replace(['http://', 'https://', 'www.'], '', $exhibition['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'exhibitions' => $exhibitions
|
||||||
|
];
|
||||||
|
};
|
|
@ -42,14 +42,14 @@
|
||||||
<div class="header-bar">
|
<div class="header-bar">
|
||||||
|
|
||||||
<nav class="header-bar__nav" aria-label="Menu">
|
<nav class="header-bar__nav" aria-label="Menu">
|
||||||
{% if site.homepage.exhibitions is not empty %}
|
{% if exhibitions is not empty %}
|
||||||
<ul class="header-bar__nav-menu">
|
<ul class="header-bar__nav-menu">
|
||||||
{% for exhibition in site.homePage.exhibitions.toStructure %}
|
{% for exhibition in exhibitions %}
|
||||||
<li class="header-bar__nav-item">
|
<li class="header-bar__nav-item">
|
||||||
{% if exhibition.external_link.toBool == false %}
|
{% if exhibition.external_link == false %}
|
||||||
<a href="{{ exhibition.url }}" target="iframe">{{ exhibition.url }}</a>
|
<a href="{{ exhibition.url }}" target="iframe">{{ exhibition.title }}</a>
|
||||||
{% elseif exhibition.external_link.toBool == true %}
|
{% elseif exhibition.external_link == true %}
|
||||||
<a href="{{ exhibition.url }}" target="_blank">{{ exhibition.url }}</a>
|
<a href="{{ exhibition.url }}" target="_blank">{{ exhibition.title }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue