Avoid clutter in your elements folder

Published on and tagged with cakephp  tip

Today, there was a question in the IRC channel how you can avoid clutter in your elements folder. Well, the answer is obvious: use folders (but I know, sometimes you are just blind and you don’t see the obvious solution *g*). You can create as many folders in your elements folder as you like. When rendering the element you just have to add the folder name as shown in the example below:

$this->renderElement('myfolder/myelement');

4 comments baked

  • gRegor

    It’s the simplest solutions that usually evade us. :)

    I like the new look. Minimal and clean, but not as plain as the absolute-minimal previous version.

  • cakebaker

    Thanks. I am glad you like the new look :)

  • Troy Schmidt

    I don’t really like the new site. I REALLY didn’t like the old one when you took it barebones. If a site does go barebones like this I like to see more Web2.0 AJAXy stuff with it instead. Just my cup of tea.

    Also, this tip can be extended to the plain old render() method as well. I used it as part of the PHPMailer Wiki Tutorial and love organizing views into meaningful folders. Makes things so much more clearer for me.

  • cakebaker

    @Troy Schmidt: Thanks for the feedback. What do you think could be improved?

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License