views:

405

answers:

3

I'm new to CakePHP. I'm keen to use the scaffolding feature to quickly generate views, and then to use bake to generate views that I can edit.

I have created custom scaffold views in app/views/scaffolds so that my scaffolded views fit in with the layout of my application. Is there any way that, when I bake views, they are based on the custom scaffolding views I created, rather than on generic views as they seem to be?

A: 

maybe you might want to try puting more css rules since when scaffolds, the generated view code is usually in a <div class='model'>.

zam3858
I have changed the CSS. I don't see <div class='model'> in either the scaffolded view or the baked view, however.
Tomba
+2  A: 

I think you have your concepts a little bit mixed up here. It's really just a matter of clarifying the terms:

  • scaffolding is something you don't really want to use except as a quick way to view data. Generally you won't edit these -- if you want to edit scaffolding, just do a bake and edit the normal views.
  • baking views - these take the templates from cake/libs and copy them over to app/views. Nothing too complex going on there, but when you want to edit the scaffolding, you do this.

So for your issue, you can probably just (temporarily) replace the files in cake/libs/view/scaffolds. I would also suggest that you replace the original scaffolding at that point, as its generally a bad practice to modify the files in the cake/ directory.

At that point, you should have the views that you want, all ready to go in your app/views directory. I would suggest from now on that you bake before you modify, so that you can just modify the views rather than having to deal with the process above.

Travis Leleu
Yes, I think I got the concepts a bit mixed up. The main reason I wanted to edit the scaffolding view templates was because the default scaffolding views didn't look right in my css layout. But I could have got the same effect by editing the view templates as you suggested, and immediately baking all the views.
Tomba
A: 

I found this page in the cakephp cookbook which explains how to edit the view templates so that baked views produce custom HTML. At least in cakephp 1.2, the view templates are copied from app/vendors/shells/templates/views (to app/views).

http://book.cakephp.org/view/789/Modify-default-HTML-produced-by-baked-templates

Tomba