why is record.twig important in bolt CMS ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

why is record.twig important in bolt CMS ?

Post by gautamz07 »

I was just going through this tutorial HERE http://www.sitepoint.com/using-boltcms- ... s-website/ , if you scroll past half the page you'll find the following section:

Retrieving Content From Database Records

The author says the following:
By default, Bolt looks for a record.twig template file to output the “record”, or the contenttype entry. If we preview that testimonial we just created, we’ll get an error thrown at us telling us that Bolt tried to use record.twig, and it doesn’t exist. Let’s create that and throw in some dummy content:
I am not quite understanding the above explanation, why is record.twig important and why will an error be throw ??

can somebody explain ? :cry:

Thank you.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: why is record.twig important in bolt CMS ?

Post by Celauran »

record.twig itself isn't technically important. In your content type definitions (contenttypes.yml) you can specify your record and listing templates. Twig is throwing an exception because you're trying to render as a view a file that doesn't exist. Bolt defaults to listing.twig and record.twig in your theme's directory, but you can customize it as needed.
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: why is record.twig important in bolt CMS ?

Post by gautamz07 »

Thanks celauran.
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: why is record.twig important in bolt CMS ?

Post by gautamz07 »

was just reading the doc's here https://docs.bolt.cm/templates-routes

so suppose i have a content type of testimonials

so now when i navigate to http://localhost:8080/boltCMS/testimonials ,

bolt will look for record.twig ? (ofcourse this con be changed in the contenttype.yml file) , but is this why record.twig is important ? i am just asking , so i am clear on this point.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: why is record.twig important in bolt CMS ?

Post by Celauran »

record.twig is the default template for individual records of any content type.
gautamz07 wrote:so now when i navigate to http://localhost:8080/boltCMS/testimonials ,

bolt will look for record.twig ?
No. /testimonial/1, for example, would load record.twig by default, but /testimonials (ie. the index page) would load listing.twig by default.
User avatar
gautamz07
Forum Contributor
Posts: 331
Joined: Wed May 14, 2014 12:18 pm

Re: why is record.twig important in bolt CMS ?

Post by gautamz07 »

Ohh yes right , i confused the two ! TY.
Post Reply