Making Websites With October CMS - Part 29 - PHP block

preview_player
Показать описание
In this episode I'm going to show you how to use PHP block in your October CMS theme to create simple and complex queries and display them on your pages.

October CMS has three main parts of it's templates. Configuration block where information about your page is contained. Twig block where your markup goes, an the one we didn't talk about - PHP block.

And PHP block is used for just that, writing PHP at the start of your template. Which is very useful if you want to prepare some data before your page renders and then display it.

Usually this means that you would be making queries of varying complexity. I would compare this to something like Custom Queries in WordPress.

As you will see, this PHP block will help you a lot when making October CMS site.

### Code used in this video

Рекомендации по теме
Комментарии
Автор

С вашим акцентом я как будто лучше понимаю английский) Спасибо вам за ваши труды!

keipa-code
Автор

These have been great. Thoughts on doing a video, or course, on Laravel's Voyager?

CoryTheSimmons
Автор

Ivan, I have a question. I want to display the values of a single movie as an array and want to use 'for loop'. Like... 'title' => 'inception', 'year' => '2012'. I could put the keys like 'title, year' in the 'itemlist' array. But I don't know how to put the values and display them.

Here are the part of the codes.
=
<?
use Jiwon\Movies\Models\Movie;
function onStart()
{
$this['movie'] = Movie::where('id', '=', $this->param('id'))->first();
$this['itemlist'] = array("title", "year", "director", "description");
}
=
{% for i in itemlist %}
<div class="propertyname">
{{ i }}
</div>
{% endfor %}

** I want to display movie values here using for loop. **
{% for ?? in ???? %}
<div class="description">
{{ ?? }}
</div>
{% endfor %}

jiwonyi
Автор

Hi Ivan ! thank you so much! the code looks shorter and simpler. ^_^
Ivan could you make videos for octobercms google analytics plugin ?

alexisteo
Автор

Hi Ivan thank you for that great tutorial, I would like to know how to make plugin contents slide. I read something about Explode but don't know how tu use it. Thnx

YassineAamou
Автор

another great tutorial.
can you make your video about making backend forms in the front end?
thank you

map