Blog posts

Mar 11

Why your Cakephp app should be made up of plugins

Written: Mar 11th 2009, 21:35

Recently I have been working on my latest Cakephp app, and found Cakephp’s plugin architecture to be a great timesaver and helper. Totally I have 12 models, but only 3 in the regular app/model directory. The rest is located under the plugins:

  • Authake (3 models) – handles users, user groups and roles
  • Newsletter (5 models) – subscribers, groups, mails and reporting
  • Comments (1 model) Build myself, and is plugable in any view since it is using the url as an relation

Both Authake and Newsletter needed some finishing and debugging, but if I was do build the same functionality myself I would have spent much more time.

Guidelines for building plugins

While taming these external plugins, you got a feel for what’s best praxis building plugins. As a short list I will emphasize these points:

  • Use conventions! Admin functions should utilize the build in admin routes!
  • Use conventions! Do NOT mock up to much with the baked views. Rather but your effort in writing smart, and good code in models, controllers, helpers and components. Avoid using icons instead of the edit, view and delete buttons/links!
  • Comment code!
  • Escape the messages with the __(“string”) function to make language translation or customization easier!
  • When deploying a plugin I tent to move some views into the main view-folder in the app directory. At least I did that with the Newsletter-plugin (see above)
  • Even though you are using SVN for your app, you can add a svn propedit svn:ignore plugins and check out other repositories in that directory
Permalink for Why your Cakephp app should be made up of plugins
Feb 02

Launch of Surdeig.no CakePHP application

Written: Feb 2nd 2009, 19:05

Screenshot cakephp application surdeig.no

I started baking a wail ago, think it must have been almost 10 years back. For many years I was like a once in a while baker, reading the recipies at the back of flour packages and happy eating theese breads. Then I discovered sourdough in a danish book about outdoor cooking, and successfully created my first sourdough culture. Call it passion, but since than I have been a weekly baker and eating my selfmade, healthy rye bread each and every day (almost).

Combined with my other “baking” passion I have now created a norwegian sourdough baking site, build in CakePHP of course! Mostly I want to share and serve knowledge about sourdough baking and other baking relative thinks I have picked up, but also try out CakePHPish this and do nice design stuff. Check it out on www.surdeig.no.

Source code is awailable on code.google.com/p/gerhardsletten/ or (directly):
svn co http://gerhardsletten.googlecode.com/svn/trunk/cakephp/surdeig

How I started baking with CakePHP

Then I found out about CakePHP in a web framework roundup in Pratical Webdesigner. Think it was the joy of a Ruby on Rails application structure combined with the fact that I didn’t had to learn another language that won me over. After a mounth of playing I was able to release my first app – my version of the famous blog tutorial hosted here at www.gersh.no (it has been refactored once since then).

Permalink for Launch of Surdeig.no CakePHP application
Dec 18

SmartMarkUp with CakePHP

Written: Dec 18th 2008, 22:15

Smarkup with Cakephp

SmartMarkUp is a lightweight textedtor in where the compressed version weights only 10kb (without css and images.

How to use in CakePHP

Adding it to CakePHP is pretty easy: Just drop it in your “js” folder, and add a symbolic link of it in your “css” folder so you can add the css as well.


// Add the stylesheets
css(‘smarkup/skins/style.css’) ?>
css(‘smarkup/skins/default/style.css’) ?>

// Add the javascript
link(‘smarkup/smarkup.js’); ?>
link(‘smarkup/conf/html/conf.js’); ?>

Then you activate it with:


.. SMarkUp.bind('PostBody', 'html', 400); ..

Follow the guide on their this page.

Permalink for SmartMarkUp with CakePHP
Dec 14

Dice Adobe Air application

Written: Dec 14th 2008, 23:45

Had some friends over at my place on saturday and for beer and “Navigare” (like the Monopoly Board Game only on the ocean). Unfortunately the dice was gone.. Well, creating a random thing shouldn’t be that hard on a computer, so I wrote this simple dice application.


Download Dice.air (Adobe Air Application)


Download Dice Source

Permalink for Dice Adobe Air application
Oct 11

Leaves are falling while I am coding

Written: Oct 11th 2008, 17:07

After a rather tough season with plenty of triathlon competions here in Norway. The main race where a Ironman in Kalmar the 2. of august, where I completed the 3.8 km swim, 180 bicycle leg and marathon on 10 hours and 15 minutes.

Since then my weekly training volume has dropped, and I have been spent more time on my new MacBook doing computer related stuff.

Things archived so far this fall

  • Did a revision of the code on this site (www.gersh.no) and upgraded to CakePHP 1.2.
  • Redesign my norwegian blog at www.gerhardsletten.no – not quite finished yet, think I might also need to do a rebranding.
  • Added some new open source project to www.gersh.no/projects that I have been having laying around.

Upcoming plans for this winter

  • This summer I have been included in the Norseman Extreme Triathlon Crew, with responsibility for their homepage at www.nxtri.com where we will move it over to the Ez publish platform and enhance usability.
  • Write a Adobe Air application for uploading images directly to your own server, and a PHP application to receive these files. Much as the Picasa or Flickr plugin for iPhoto, but on your own server.
  • Write a new version of WorkTimer in Adobe Air, but maybe with some new features. I have been receiving a lot of wishes via mail, and I also would like to add some “Scrum” functionality like Scrumworks.
  • With my new work at www.netmaking.no – a Ez partner here in Oslo I will probably be doing a lot of stuff in the Ez to.
  • Working on my norwegian sourdough site www.surdeig.no. A lot of people have signed up!

Guess it won’t be a lazy winter for me..

Permalink for Leaves are falling while I am coding
Sep 22

Automator workflows for batch process images and photos

Written: Sep 22nd 2008, 19:14

Automator workflow - batch scale photos

Even though Apple has hidden the Automator workflows for Finder deeper down in the GUI, they are still very useful for doing batch actions. Both home and at office I use this collections of workflows every day. Almost!

Image utility workflows

  • Add to iPhoto Adds image to Apple iPhoto
  • Change Image Type Batch change image to the following formats: BMP, JPEG, JPEG 2000, PICT, PNG or TIFF
  • Crop Photos Batch crop images by pixel or percent
  • Flip Photos Batch flip your photos
  • Frame Images Batch add a black border around your photos
  • Print Photos Batch print your photos
  • Rotate Photos Batch rotate your photos
  • Scale Photos Batch scaling your photos

Web workflows

  • Make names webfriendly Batch transform filenames to webfriendly format

To make this Automator Workflows avaiable from Finder, drop them into:
/Users//Library/Workflows


Download these Automator Actions here

Permalink for Automator workflows for batch process images and photos
Aug 28

Upgraded my blog to CakePHP 1.2

Written: Aug 28th 2008, 19:52

Screendump of inline editing with CakePHP

Just upgraded this blog to CakePHP 1.2. Most stuff seems to work by now, but there is still some bits and pieces that needs to be figured out. Developing in Cake is always fun, and I with the new 1.2 version, its even easier.

Features of my new CakePHP app


  • Instead of handling to separate layouts, one for frontend and one for backend, I mashed these together. With the Auth components and inline editbuttons both are integrated both into one piece.

  • The static pages are still filebased (default CakePHP) but I plan on moving that content into the database as well.

  • Did drop all rich texteditors though. First off they are pretty huge in size (300-700 kb), and getting them to work the way you want is a pain in the ass. Think I rather try to write some own javascript to insert complicated tags and to convert code to entities

  • Also created a settingscontroller to keep all the settings like meta, title of site and stuff like that.

  • Permalink for Upgraded my blog to CakePHP 1.2
    Jul 22

    Beta invitation for Aviary Webapps

    Written: Jul 22nd 2008, 22:06

     Aviary homepage

    Today I recieved a beta invitation to Aviary – a collection of online applications for “image editing to typography to music to 3D to video”. By now it only seems I have access to Phoenix – a image editor and Peacook – a pattern creator.

    Permalink for Beta invitation for Aviary Webapps
    Jul 22

    Creating a Design Extension in Ez Publish

    Written: Jul 22nd 2008, 10:46

    Moving your basic templates and CSS into an extension will ease the workflow in setting up new sites with Ez Publish.

    First off create a folder in the extension folder (/ezpublish/extension) of your Ez distribution. To make it work as an design extension we just need a few files:

    /gersh<br>&nbsp;&nbsp; &nbsp;/design<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/gersh<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/images<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/override<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/stylesheets<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/templates<br>&nbsp;&nbsp; &nbsp;ezinfo.php<br>&nbsp;&nbsp; &nbsp;/settings<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;design.ini.append.php

    File listing “ezinfo.php”:

    &lt;?php<br>class gershInfo<br>{<br>&nbsp;&nbsp;&nbsp; static function info()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return array( 'Name' =&gt; "Gersh Design Extenison",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Version' =&gt; "1.0.0",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Copyright' =&gt; "Copyright (C) 1999-2007 Gersh.no",<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'License' =&gt; "GNU General Public License v2.0"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp;&nbsp; }<br>}<br>?&gt;

    File listing “design.ini.append.php”:

    &lt;?php /* #?ini charset="utf-8"?<br>[ExtensionSettings]<br>DesignExtensions[]=gersh<br>*/ ?&gt;

    Make sure you activate your new extension in “ezpublish/settings/override/site.ini.append.php“:

    [ExtensionSettings]<br>ActiveExtensions[]<br>ActiveExtensions[]=gersh

    And add it as an additional site design list in “ezpublish/settings/siteaccess/<site-name>/site.ini.append.php

    [DesignSettings]<br>SiteDesign=ezwebin_site<br>AdditionalSiteDesignList[]<br>AdditionalSiteDesignList[]=gersh<br>AdditionalSiteDesignList[]=base
    Permalink for Creating a Design Extension in Ez Publish
    Jul 12

    New MacBook - How to setup Apache, PHP and MySQL

    Written: Jul 12th 2008, 20:32

    My new MacBook - closeup

    After 3 years with my old Imac, I have finally bought a new MacBook. The screen is tiny, but I guess I will get used to it. I am very exicted, but before any real joy can begin, I need to install all the thing I need for my use as “Webdesigner/Webdeveloper”.

    Permalink for New MacBook - How to setup Apache, PHP and MySQL

    Page 2 of 4

    << previous | 1 | 2 | 3 | 4 | next >>