Page 1 of 1

template not being populated with values

Posted: Mon Jan 04, 2016 3:20 am
by gautamz07
I have the following code in my index.twig file:

Code: Select all

{% include '_header.twig' %}

<main>
  <div class="container">
    <div class="page-header">
      <h1>{{ testimonials.name }} | <small>{{ testimonials.position }}</small></h1>
      <time>{{ testimonials.datecreated|date("jS F, Y") }}</time>
    </div>
    <div class="page-content">
      {{ testimonials.body }}
    </div>

  </div>
</main>

{% include '_footer.twig' %}
yet i am getting a blank page , see HERE http://i.imgur.com/s5cPndG.jpg WHY ?

My database is populated .

Re: template not being populated with values

Posted: Mon Jan 04, 2016 6:34 am
by Celauran
Is testimonials a collection? If so, you'll need to iterate over it. https://docs.bolt.cm/record-and-records#using-records

Re: template not being populated with values

Posted: Mon Jan 04, 2016 7:59 am
by gautamz07
Opps yes it is , Totally forgot that , silly me. I believe if it were the testimonials.twig file the testimonial record would be available by default (note sure !), but i have the code in my index.twig , i changed the code to the below now:

Code: Select all

{% include '_header.twig' %}

<main>
  <div class="container">
    <div class="page-header">
      <h1>Testimonials</h1>
      <p>All the testimonials for this great company be here.</p>
    </div>
    <div class="page-content">
      {% for testimonial in testimonials %}
        <div class="testimonial">
          <h3>{{ testimonial.name }} | <small>{{ testimonial.position }}</small></h3>
          <p>{{ testimonial.body|excerpt(100) }}</p>
        </div>
      {% endfor %}
    </div>
  </div>
</main>

{% include '_footer.twig' %}
But my template is still not being populated with data.