Where is ct defined and how can i show records in index.twig
Posted: Thu Oct 13, 2016 1:50 am
How do i display a few records in bolt in my index.twig file ?
What i have done is i have just deleted the index.twig and made a new index.twig file which is pritty much a blank html document with the following code in it:
As of now when i load the file , and check in the browser i see the content in the else clause displayed . Now at the start of the code i have the below lines of code:
But the problem is when i dump ct it shows me null in the Browser. And when i check any other template in the default theme i don't see ct defined using setcontent
as you can see records is defined HERE https://github.com/bolt/bolt/blob/relea ... e.twig#L61
But where is ct defined ??
What i have done is i have just deleted the index.twig and made a new index.twig file which is pritty much a blank html document with the following code in it:
Code: Select all
{% dump(ct) %}
{% setcontent records = ct.slug ~ "/latest/3" %}
{% set records = records|order(app.config.get('general/listing_sort')) %}
{% for record in records %}
<article>
<h2><a href="{{ record.link }}">{{ record.title }}</a></h2>
{{ popup(record.image, 1200, 500) }}
{# display something introduction-like.. #}
{% if record.introduction %}
{{ record.introduction }}
{% elseif record.teaser %}
{{ record.teaser }}
{% else %}
<p>{{ record.excerpt(300, false, search|default('')) }}</p>
{% endif %}
{% include 'partials/_recordfooter.twig' with { 'record': record } %}
</article>
{% if not loop.last %}
<hr>
{% endif %}
{% else %}
<article>
<h2>{{ __('general.phrase.no-content-found') }}</h2>
<p>
{{ __("Unfortunately, no content could be found. Try another page, or go to the <a href=\"%paths_root%\">homepage</a>.", {'%paths_root%': paths.root} ) }}
</p>
</article>
{% endfor %}
As of now when i load the file , and check in the browser i see the content in the else clause displayed . Now at the start of the code i have the below lines of code:
Code: Select all
{% dump(ct) %}
{% setcontent records = ct.slug ~ "/latest/3" %}
{% set records = records|order(app.config.get('general/listing_sort')) %}
as you can see records is defined HERE https://github.com/bolt/bolt/blob/relea ... e.twig#L61
But where is ct defined ??