How to iterate over only a specific contenttype ??
Posted: Tue Nov 01, 2016 3:29 am
I have a new difficulty
, just need some help with this. I have the following lines of code in my aside.twig file:
This basically iterates over all the contenttypes in my `contenttypes.yml` file and i get the following in front end:
http://imgur.com/a/6eDfN
Now what i want is only recent entries, so i tried modifying the following line of code:
To the following:
{% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) and app.config.get('contenttypes') == "entries" %}
But i get an error , so how exactly do i modify the following line of code:
So that i get only the records of "entries" contenttype ??
Thank you.
Gautam.
Code: Select all
{% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) %}
{% setcontent records = ct.slug ~ "/latest/3" %}
<h5>{{ __('contenttypes.generic.recent', {'%contenttypes%': ct.slug}) }}</h5>
<ul>
{% for record in records %}
<li><a href="{{ record.link }}">{{ record.title }}</a></li>
{% else %}
<li>{{ __('contenttypes.generic.no-recent', {'%contenttype%': ct.slug}) }}</li>
{% endfor %}
</ul>
<p><a href="{{ paths.root }}{{ct.slug}}">{{ __('contenttypes.generic.overview',{'%contenttypes%': ct.slug}) }} »</a></p>
{% endfor %}http://imgur.com/a/6eDfN
Now what i want is only recent entries, so i tried modifying the following line of code:
Code: Select all
{% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) %}{% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) and app.config.get('contenttypes') == "entries" %}
But i get an error , so how exactly do i modify the following line of code:
Code: Select all
{% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) %}Thank you.
Gautam.