CodeIgniter 4 from Scratch - #8 - Views | View Layouts | Part 3/3

preview_player
Показать описание
In this video of CodeIgniter 4 From Scratch Series we will learn how to use View Layouts. This is a third and last part of Views sub-series, where you will learn how you can create CodeIgniter Layout and extend it with a view file, so that you don't have to repeat your code in every controller by trying to echo all of the parts of your HTML.

View Layouts will help you achieve the following:

- keep your controllers clean
- make your HTML easy to maintain
- now you will 'return' just one view file instead of 'echo' many files
- no code repetition

This is a last part of CodeIgniter 4 Views so if you have watched this video, then you should feel comfortable about how to structure your views files so that your code stays maintainable, clean and without repetitions.

CodeIgniter 4 From Scratch Series, the series that are intended to help you get started with CodeIgniter 4 even if you have never worked with PHP frameworks before.

This course will not only help you get started with CodeIgniter but also will help you understand the way PHP Frameworks work.

For more information about CodeIgniter 4 View Layouts read the official docs
Рекомендации по теме
Комментарии
Автор

I really thank you for these videos, they are so helpful.

mariepgozzer
Автор

These are great thanks! Is the finished project in a GH repo?

drjonbear
Автор

Hi, I get this error Use of $this in global code might be unatendedPHP(PHP0437). It appears if I use the extend and render method.
Can you tell me what cause this error and how to fix this?

konam
Автор

Hey Alex, What's the real benefit of using layouts over just views? Because for the benefit you mentioned, I could just create a render method in the BaseController, and could take care of the 3 echos in that method, which is actually superior, because then I can also do additional data passing or whatever at that level.

szaboistvan
Автор

Hi, is it possible to pass a "parent" layout to a view programmatically?

filippolevizzani
Автор

late to the party here...these are quite good, thanks for the vids. I assume that layouts can include view cells (e.g. referencing discrete header, footer files!)

robrussell
Автор

l would like to appreciate for the great videos, thank you!

nanohetube
Автор

Very nice and useful ! What if we have queries from database in the footer ? how should be code this ? (eg: a widget in the footer that list the blog categories)
Thank you Alex

outstyler
Автор

Call to undefined method
I can't extend to the template

ikbarrahma
Автор

Hi Alex, can you kindly answer my previous question? how to load meta description, title in layout view.

JeewakaKarunaratne
Автор

Hi Alex, your tutorial is super useful. Would be really appreciated if you can upload the source code of this series to youtube. Thank you so much

sekfook
Автор

Hi Alex, thank you explaining in such detail. I've one question, how we change title of main layout page. So that every page should have separate title.

musaddiqktk
Автор

Hi Alex, please make a video about how to add blade template engine to codeigniter 4

darleneabigail
Автор

Dear Alex, thank you for educating about layout. i have two questions,
1) you showed load one page using layout with 'content' tag, so each page 'content' tag to use to load layout?
2) for navigation how to load layout and content page?

JeewakaKarunaratne