Questions tagged [twig]

Twig is a modern, fast, flexible, and secure templating engine for PHP.

Filter by
Sorted by
Tagged with
2 votes
1 answer
278 views

PHP OOP: Configuring MySQL DB & query w/ Twig

I decided to up my PHP game and learn some OOP. I am re-building my website from procedural to OOP, but since I don't want to use a full framework I fiddle with some components. As a router I use ...
bender's user avatar
  • 21
3 votes
2 answers
310 views

A contact form with CodeIgniter and Twig

I am working on an online newspaper/blogging application with CodeIgniter 3.1.8 and Twig. I use the Twig template engine for the front-end views. I have put together this simple contact form which ...
Razvan Zamfir's user avatar
1 vote
2 answers
369 views

Implementing Pagination with Twig in Codeigniter 3

I am working on a online newspaper/blogging application with CodeIgniter 3.1.8 and Bootstrap 4. I have decided to add themes to it. The application is not HMVC, only MVC. I thought it was a good idea ...
Razvan Zamfir's user avatar
1 vote
2 answers
233 views

Improving upon basic MVC in PHP

I've put together a simple CRUD application to keep track of my library of books in an effort to learn the model-view-controller pattern, as well as better myself at PHP. Everything I have works so ...
Robert Holman's user avatar
3 votes
1 answer
785 views

Simple CSS minifier for twig, with basic caching

On part of a project, I have some CSS being read using twig's source() function. But sending a huge chunk of CSS is not optimal. To reduce the size of the HTML, I'...
Ismael Miguel's user avatar
4 votes
1 answer
222 views

Javascript contact form validation code

I'm a UI / UX Designer trying to sharpen my JS skills. I wanted someone else to check this code snippet and maybe have a Pro tip to improve or shorten it. Javascript: ...
Lukas Hillebrand's user avatar
3 votes
1 answer
810 views

Raw filter with ternary operator for html class attribute

I've been trying to figure out how to stop Twig escape using the following code, which I feel is a little nicer with the succinct ternary operator. I hope someone can confirm I'm using the correct ...
Rob's user avatar
  • 157
1 vote
1 answer
44 views

Should I include a view for each message?

For now, I have two views using Twig: messages.html.twig item.html.twig The first one is the view which displays all of the users' posts in my forum. When a user post a new message, it's done via ...
Madnx's user avatar
  • 207
2 votes
1 answer
317 views

Receiving data from a database

I am learning OOP using PHP5 and I wrote two simple classes for receiving data from a database using the dependency injection pattern and rendering a grid with Twig. Does this code have sense for OOP ...
Pablo Rebolini's user avatar
4 votes
1 answer
1k views

Optimizing a table - Twig, CSS

I have a table with forms in two colors - the first row is one color, the second is the other. Can you please tell me if there is a way to optimize my code (such as with this)? I have two CSS classes:...
Faery's user avatar
  • 269