Overview
Today I’ll show you how you can use cakePHP layout files and elements. This way you can easily create different layouts for your pages and with elements you can write efficient code instead of copy/pasting the same code over and over again.
In this tutorial I’ll be covering
- Explain layouts
- Create 2 different layouts, one for regular users and one for the admin
- Explain elements
- Create an element and pass data to it
This part is the follow-up on what we have seen in CakePHP Basics Tutorial – Part 4.
This part is the follow-up on what we have seen in part 4 of my CakePHP basics serie!
Let me know if you enjoyed it!
Happy coding!
27 Responses
Hi!
I followed all your tuts and I’m now doing a tut from the CakePHP Cookbook.
But in the cookbook they always include components and helpers at top of the controller which you haven’t done once in your tuts.
But it still works. Why is that? Is it optional to include them?
Eg: http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html#adding-posts
public $helpers = array(‘Html’, ‘Form’, ‘Session’);
public $components = array(‘Session’);
Kind regards,
WouterDS
Html, form, session are core components and will be loaded by defaults.
It’s only when you override the helpers/components array that you have to include them manually again.
Oh and for the next video could you show you would retrieve data from multiple tables on a specific page? Eg: On the homepage I want to show the total products, total users and the last 3 added users and last 3 added products.
Hmm, the word “how” is missing in that question.
By using the $uses array you can add multiple models to one controller. So if you add $uses = array(‘Products’, ‘Users’);, cakePHP will make these models available in your controller!
I think you are doing a great job with your tutorials and I am finding them helpful and interesting. I was hoping you could do a tutorial on building a complete application such a shopping cart. I am having problems trying to understand passedArgs function and named parameters and was hoping you could help me out by explaining how it works, that is how to reference them within controllers and models
Great work..
We are waiting for your next tutorial.
I am still little bit confusing in naming conventions.
Nice Work … I hve seen u r all tuts .. Can u provide any tut on Tree / and ACL bhehaviours .
Hi!,
l have followed you tutorials and it was great. l want to ask, can we always put one content per page i.e fetch(‘content’);?>
hello i want the tuitorials from start to finish in cake php
great work.
Hey man, thanks for doing these tutorials, they’re amazing. Keep posting!
Frederik,
Thanks for creating the tutorials – very helpful and the best I have found! I have a question about your phpstorm setup. Have you done anything to phpstorm for enabling autocomplete? I am not getting some of the same autocomplete options and was wondering if you would mind giving a hint for setting phpstorm up for cakephp development….thanks in advance!
Hi ! I have been following all your tutorials. Its really good. Can you tell me how to use single core for multiple apps ?
Hi. I really have to thank you. You made things clearer to me. Keep making tutorials, they’ve got a talent for that.
sir your work is great.and you are greate person
sir i am wating your next tutorail
sir plz upload new tutorails
sir you are rockstar
I’m kinda really swamped with work at the moment. I hope to do some new ones in 2014!
Happy xmas!
Hi Frederik,
Thanks a lot for your tuts, you re really helping me out to get some good fundaments on cakephp.
Just wondrering though, is there any way to implement a templating language eg. Liquid in cakephp ???
Thanks again,
keep on.
Hey,
Great series and i have just cleared my basics in CakePHP.So now will implement it in a small application and in case of any problem i will post it here.
Moreover,awesome work really.
Looking forward for new topics.
I have a ques:
After login when i click back button it again opens login form ,how can i get it fixed ??
Great tutorial
awesome tutorials expecting next series of tutorial
fantastic tutorial – the best I’ve seen so far. Would I be asking too much if I wanted to download this video? Would truly appreciate the favour…
CakePHP Basics Tutorial – Part 6 ?????????????????????????????????????????????????
sir where tutorail # 6
Wow i hate CakePHP so much. all these magic function are so annoying and to code in CakePHP is simply confusing and too much of OOP.
The download does not work (404 error)