zen of coding

Take control over your “bake” and “scaffold” HTML templates

Excellent tips from Mark Story, which popped up on IRC yesterday…

They are very useful to some, I can imagine… so here it goes…

How to modify your scaffolding HTML
(If using var $scaffold for prototyping your app)

  1. Go into: cake/libs/views/scaffolds
  2. Notice the 3 files there (add/edit actions work in the same manner)
  3. Copy them to your: app/views/scaffolds
  4. Make changes to the HTML output as you wish

How to modify your “bake” HTML output
(If you are using bake console this one is quite important)

  1. Go into: cake/console/libs/templates/views
  2. Notice the 4 files there
  3. Copy them to your: app/vendors/shells/templates/views
  4. Make changes to the HTML output to control the way “bake” builds your views

Simple, but powerful… thanks, Mark!

  • Nice to see these posted somewhere, I actually have some nice scaffolds sitting around, I should finish off the bake templates and release them one day.

  • @Mark Story

    I was thinking of adding this to the cookbook, but then I didn’t find an appropriate section… and then I got side-tracked with some random crap…

    But, I definitely feel it deserves to be there and I’ll get back to it ASAP. Just wanted to write it down, so I don’t forget myself. :)

  • Pingback: Webmaster Crap » Blog Archive » Take control over your “bake” and “scaffold” HTML templates « nuts …()

  • @teknoid: I often find that issue myself when thinking of adding things to the cookbook. ;) Regardless, thanks for writing it down!

  • @Brendon Kozlowski

    No problemo ;)

  • Pingback: CakePHP Digest #7 - The Rise of the Plugin | PseudoCoder.com()

  • Is there any guidance on modifying the skeleton structure? I want to modify the CSS and home.ctp as well, without modifying the core files. Is this possible?

  • @Amit

    I think in this case it’s best to go ahead and modify the files within your app/views/… and app/webroot files. (If I understood your question correctly).

  • Thanks teknoid – that’s how I accomplish it now, but I was hoping there might have been a more reproducible way. I create tiny apps for family all the time and would love it if I could create a new CakePHP project that already had my skeleton design implemented. Right now I do what you suggest, and just copy/paste files into app/webroot.

    If you discover a reproducible way of quickly applying a common site design to a new project, I’m all ears! Thanks again for this site and the work you do.

  • @Amit

    Depending on the IDE that you use you can check out a “skeleton” project each time from the cake’s repository (via SVN, as an example). Now, I can’t say that it is necessarily faster or better than a simple copy/paste. On top of that you could create your own repository and just check out new apps with your particular settings for each new project.

    However, one thing to note is that depending on the core updates the “app” base does change from release to release, although not often and not overly significant you do want to usually have the latest and the greatest. Hope this helps or at least sets you in the right direction.

  • Pingback: Take control over your “bake” and “scaffold” HTML templates | Dailytuts.net - Daily tutorial for peoples()

  • Thanks for this one. I did wonder how it could be done a few days back when I had to modify all the views that cake baked for me to the one I wanted.

  • @nigelbabu

    Glad to hear it helped.

%d bloggers like this: