-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_aside.twig
63 lines (40 loc) · 2.33 KB
/
_aside.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<div id="secondary" class="widget-area col-md-4" role="complementary">
{{ widgets('aside_top') }}
<aside id="about" class="widget widget_aldehyde_rp"><h1 class="widget-title">About</h1>
<ul>{# The next section attempts to fill the panel in the sidebar with part of the
'about'-page, if it exists. First, attempt to fetch a page with slug 'about' #}
{% setcontent about = "page/about" %}
{# check if we have a title. If so, we know we have a page. Otherwise, still
print a text, telling us to create the 'about' page. #}
{% if about.title is defined %}
<h5>{{ about.title }}</h5>
{{ about.teaser }}
<a href="{{ about.link }}">{{ __('Read more') }} »</a>
{% else %}
<h5>{{ __('Alas, no about!') }}</h5>
<p>{{ __("If there was a Page with 'about' for a slug, it would've been shown here. But there isn't one, so that's why you're seeing this placeholder.") }}</p>
{% endif %}
</ul>
</aside>
<aside id="aldehyde_rp-2" class="widget widget_aldehyde_rp"><h1 class="widget-title">Latest Articles</h1> <ul class="rp">
{# The next section iterates over all of the contenttypes, and prints a list
of the five latest records of each of them. The 'magic' happens in the
setcontent tag.. ct.slug ~ "/latest/5" contatenates the slug ot the
contenttype with /latest/5, so it becomes something like "pages/latest/5".
The 'else' in the inner for-loop is only used if there are no 'records',
so we can use it to print a helpful message.
Lastly, "{{ paths.root }}{{ct.slug}}" will output something like '/pages',
effectively creating a working link to that contenttpye's listing page.#}
{% for ct in app.config.get('contenttypes') %}
{% setcontent records = ct.slug ~ "/latest/5" %}
{% for record in records %}
<li class='rp-item'>
<div class='rp-thumb'><a href="{{ record.link }}"><img src="{{ record.image|thumbnail(150, 150) }}" class="attachment-thumbnail wp-post-image" /></a></div>
<div class='rp-title'><a href="{{ record.link }}">{{ record.title }}</a></div>
</li>
{% endfor %}
{% endfor %}
</ul>
</aside>
{{ widgets('aside_bottom') }}
</div><!-- #secondary -->