Move more logic into Twig filter
This commit is contained in:
parent
dca8b1afb4
commit
97050c7f29
|
@ -1,13 +1,9 @@
|
||||||
<div class="mt4">
|
<div class="mt4">
|
||||||
<h2>Events</h2>
|
<h2>Events</h2>
|
||||||
|
|
||||||
{% set talks = [] %}
|
{% set data = { talks: [page], events: site.events } %}
|
||||||
{% for event in page.events %}
|
{% include "talks-table" with {
|
||||||
{% set talks = talks|merge([{
|
talks: data|format_talks|reverse,
|
||||||
event: event|merge(site.events[event.event]),
|
talk_page: true
|
||||||
talk: page,
|
} %}
|
||||||
}]) %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% include "talks-table" with { talk_page: true } %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,18 +10,9 @@ use: [talks]
|
||||||
|
|
||||||
<h2>Last 5 Talks</h2>
|
<h2>Last 5 Talks</h2>
|
||||||
|
|
||||||
{% set talks = [] %}
|
{% set data = { talks: data.talks, events: site.events } %}
|
||||||
{% for talk in data.talks %}
|
|
||||||
{% for event in talk.events %}
|
|
||||||
{% set talks = talks|merge([{
|
|
||||||
event: event|merge(site.events[event.event]),
|
|
||||||
talk: talk,
|
|
||||||
}]) %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% include "talks-table" with {
|
{% include "talks-table" with {
|
||||||
talks: talks|format_talks|slice(0,5)
|
talks: data|format_talks|slice(0,5)
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
<p>Upcoming talks can be found in the <a href="{{ site.url }}/talks/archive">talks archive</a>.</p>
|
<p>Upcoming talks can be found in the <a href="{{ site.url }}/talks/archive">talks archive</a>.</p>
|
||||||
|
|
|
@ -14,16 +14,7 @@ talks:
|
||||||
---
|
---
|
||||||
<p>Here are a list of my previous conference and user group talks:</p>
|
<p>Here are a list of my previous conference and user group talks:</p>
|
||||||
|
|
||||||
{% set talks = [] %}
|
{% set data = { talks: data.talks|merge(page.talks), events: site.events } %}
|
||||||
{% for talk in data.talks|merge(page.talks) %}
|
{% include "talks-table" with { talks: data|format_talks } %}
|
||||||
{% for event in talk.events %}
|
|
||||||
{% set talks = talks|merge([{
|
|
||||||
event: event|merge(site.events[event.event]),
|
|
||||||
talk: talk,
|
|
||||||
}]) %}
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% include 'talks-table' with { talks: talks|format_talks } %}
|
|
||||||
|
|
||||||
<p>Upcoming talks can be found on the <a href="{{ site.url }}/talks">talks page]</a>.</p>
|
<p>Upcoming talks can be found on the <a href="{{ site.url }}/talks">talks page]</a>.</p>
|
||||||
|
|
|
@ -17,11 +17,22 @@ class FormatTalksExtension extends Twig_Extension
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatTalks($talks)
|
public function formatTalks($data)
|
||||||
{
|
{
|
||||||
return collect($talks)
|
$event_data = $data['events'];
|
||||||
->sortByDesc('event.date')
|
|
||||||
->all();
|
$talks = [];
|
||||||
|
foreach ($data['talks'] as $talk) {
|
||||||
|
foreach ($talk['events'] as $event) {
|
||||||
|
$event = array_merge($event, $event_data[$event['event']]);
|
||||||
|
|
||||||
|
$talks[] = compact('talk', 'event');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return collect($talks)
|
||||||
|
->sortByDesc('event.date')
|
||||||
|
->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Reference in a new issue