Hi!
I have a contenttype news and blog. Those two i would like to combine in a list (ordered by date) on the homepage. But the setcontent only gives a array for 1 contenttype. How could i combine two contenttypes in setcontent?
~ Dorien
{% setcontent newsItems = "nieuws-item/latest/3" %}
{% setcontent blogItems = "blog-item/latest/3" %}
{% set newsBlogItems = newsItems %}
{% set newsBlogItems = newsBlogItems|merge(blogItems) %}
{% for newsBlogItem in newsBlogItems %}
{{newsBlogItem.title}}<Br>
{% endfor %}
new \Twig_SimpleFilter('datesort', array($this, 'datesort'))
public function datesort($array)
{
usort($array, function ($a, $b) {
$first = new \DateTime($a->values['datepublish']);
$second = new \DateTime($b->values['datepublish']);
if ($first < $second) {
return 1;
} elseif ($first > $second) {
return -1;
}
return 0;
});
return $array;
}
Users browsing this forum: No registered users and 4 guests