PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Sep 16, 2019 9:01 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Oct 13, 2016 1:50 am 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
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:

Syntax: [ Download ] [ Hide ]
{% 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:

Syntax: [ Download ] [ Hide ]
{% dump(ct) %}

{% setcontent records = ct.slug ~ "/latest/3" %}
           
{% set records = records|order(app.config.get('general/listing_sort')) %}
 


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 ??


Top
 Profile  
 
PostPosted: Thu Oct 13, 2016 7:00 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada
I don't understand. It's defined in the line above the one you highlighted. for ct in...

_________________


Top
 Profile  
 
PostPosted: Sat Oct 15, 2016 3:06 am 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
Huh ....... maybe i am not seeing things right :| , but can you tell me where exactly it is defined , i mean highlight the line ?

BTW , i saw the below line on another forum and it helped me iterate over and display all my enties on the homepage :D so problem solved :D

Syntax: [ Download ] [ Hide ]
{% setcontent entries = "entries/latest/6" allowpaging %}
{% for entry in entries %}
{% endfor %}
 


But i still can't understand where ct is defined .

P.S. sorry for my irritating questions :P


Top
 Profile  
 
PostPosted: Sat Oct 15, 2016 7:08 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6425
Location: Montreal, Canada

_________________


Top
 Profile  
 
PostPosted: Sun Oct 16, 2016 4:55 pm 
Offline
Forum Contributor
User avatar

Joined: Wed May 14, 2014 12:18 pm
Posts: 331
Hey sorry celauran .

I was searching everywhere to see something like

Syntax: [ Download ] [ Hide ]
setcontent ct ...
 


since i taught variable get defined using setcontent , i totally would't guess the below line was the definition of ct

Syntax: [ Download ] [ Hide ]
 {% for ct in app.config.get('contenttypes') if not ct.viewless|default(false) %}
 


Thanks though. I'll go read about more about twig and bolt and try and ask more intelligent questions :D :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group