Monday, June 1, 2015

Record Retrieval and Pagination in Bolt CMS

Bolt is a lightweight CMS built on Silex with Symfony components that’s fast, easy, and fun to develop with. My recent affinity for Bolt has turned it into my CMS of choice as I make a conscious effort to choose wisely and step away from bloated frameworks. Previously, I gave a very detailed insight into what it’s like developing with Bolt.

Bolt CMS

Today, we’re going to break down a very popular task into steps in order to accomplish it with ease. Here’s what we’ll be doing:

  1. We’ll create a content type for news articles to include a title, excerpt, featured image, and body.
  2. We’ll retrieve the news articles, and display them “blog” style, including pagination.
  3. Each news article in the feed will link to its dedicated page, where the full article will be displayed.
  4. On the full article page, we’ll generate links to previous and next articles.

Before we dive in, let’s outline the path we’ll take to make it all happen. First, we’ll grab a fresh install of Bolt via Git and Composer. We’ll be using an SQLite file-based database, as it’s ready to go out of the box and requires no configuration. For quick front-end templating, we’ll pull in a free Boostrap theme from Bootswatch. Bolt leverages Twig, which is a modern templating engine for PHP, so we’ll build a quick theme from scratch using Twig markup. Once we’re all set up, we’ll create our content type, add in some dummy data, and output it onto a page. We’ll keep adding dummy data until we have enough to apply paging, then we’ll link to individual articles and generate previous and next links. Without further ado, let’s dive in!

Continue reading %Record Retrieval and Pagination in Bolt CMS%


by Nick Salloum via SitePoint

No comments:

Post a Comment