Viewing Posts in CakePHP

Full CakePHP 1.2 App Part 12

5th September 2008 CakePHP
CakeCatalog Main Index Page

OK so finally the full CakePHP application is coming to a close and this article is just going to wrap up a few loose ends. I've noticed a few errors and layout issues that I'm going to fix and hopefully by the end of the article the app will be fully complete.

Like all applications you could probably keep going forever adding new features, tweaking code and cleaning things up but there must come a time when you have to release it and the close the door. After this I probably wont be adding more features for some time but I do have a few ideas about great features you could try and implement.

The application can be found online at cakecatalog.jamesfairhurst.co.uk with a few more DVDs added.

7 comments Read More

Validating CakePHP Data From Another Model

29th August 2008 CakePHP

In this article I'm going to go through the steps of validating CakePHP data from another Model. More specifically if you are building a Blog Application this article will demonstrate a way of validating Comment data if the add comment form is on the Post view Page.

This is something which pops up frequently on the CakePHP Google Group and is something that I've always wanted to achieve but never got round to coding a solution.

0 comments Read More

CakePHP Image Resizer

21st August 2008 CakePHP

I'm currently in the process of building a new CMS in CakePHP and wanted to beef up the image capabilities so that I could upload an image once and then be able to resize the image on the fly by specifying a width/height.

I found a nice plain PHP script which does the job but I wanted something that works with CakePHP so I initially went the Helper route using this I found in the bakery. Although this is great I really wanted to resize images by changing values in the url and this is what I came up with.

0 comments Read More

Full CakePHP 1.2 App Part 11

3rd August 2008 CakePHP

Wow, just looked back at my last post date and realised its been a while. Anyway here's the latest post on creating a full application in CakePHP. Last time I finished off the header and this time I'm going to finish the footer. Check out the online version of the app cos I've been busy adding Dvds and its looking good.

From the view file I'm going to use the $this->requestAction() method to get data from the Dvd Controller. The requestAction() method is used to call a Controller's action from anywhere and can be extremely useful in our view files for requesting specific chunks of data.

0 comments Read More

Full CakePHP 1.2 App Part 10

8th July 2008 CakePHP

Welcome to the 10th article in my series about creating a full CakePHP application from start to finish, cant believe I've managed to fill this much space with a single application but its still going and finally taking some shape and its looking pretty, pretty, pretty good (Curb your Enthusiasm Reference - Great Show).

In this article I'm going to be finishing off the header and footer of the main DVD page by adding some functionality to the form and creating some re-usable elements which grabs data from the database. I'm also going to be cleaning a few things up as and when I come across them.

8 comments Read More

Full CakePHP 1.2 App Part 9

27th June 2008 CakePHP
Cake Catalog Main Index Page

I've been a bit slow on the updates recently, been super busy with life and everything but thats no excuse. In my last article I went through the process of turning a Photoshop design into HTML/CSS and now its time to get CakePHP involved.

In this article I'm going to transfer the design and code over to CakePHP by using a new Layout and making use of some elements, this isn't necessarilly hard to do but the process it quite involved so I'm going to break it down.

1 comment Read More

Full CakePHP 1.2 App Part 8

10th June 2008 CakePHP

Howdy and welcome to the 8th article I finally got my ass in gear and started to write it so here it is. Last time I went through my design process and came up with a Photoshop mockup of what the design will look like.

In this article I'm going to be coding up my design in HTML/CSS ready for integration with CakePHP. I always try to write clean and semantic code which validates so thats going be important during this article, I also try to avoid CSS hacks and seperate style sheets for the different browsers which means that testing your code at each step in a variety of browsers is a must.

1 comment Read More

Full CakePHP 1.2 App Part 7

31st May 2008 CakePHP
CakeCatalog Logo

Welcome to the 7th Article about creating an online application using CakePHP 1.2. In my previous post I went through the process of implementing a basic user authentication system which will require an admin user to enter a username/password to access any of the admin controller actions.

This article is going to be a bit of diversion away from coding and will focus on the design of the application. More specifically the front end of the application and how visitors will see the front page. I'm going to show you a few places I go for design inspiration and the process involved with coming up with a design for my dvd catalog application which I've coined "CakeCatalog".

2 comments Read More

Full CakePHP 1.2 App Part 6

22nd May 2008 CakePHP
CakePHP Login Screen

In this article I'm going to create a simple user authentication system whereby users will have to login to access any admin controller action. This is quite a basic application so I'm using the Session route of identifying a logged in user instead of the ACL route.

1 comment Read More

Full CakePHP 1.2 App Part 5

16th May 2008 CakePHP
DVD Catalog CakePHP Application

Welcome to the 5th Article in the series about creating a full CakePHP 1.2 Application, last time I setup the DVD Controller and View files and I'm now able to start adding DVDs to the system. As a side note I've put the application online at dvd.jamesfairhurst.co.uk so you can have a poke around and see how the application is shaping up.

In this Article I'm going to be dealing with the Genres section of the application so I can start to add / edit / delete Genres from the database. The relationship between DVDs and Genres is a HasAndBelongsToMany (HABTM) which means that a single DVD can have multiple Genres and a Genre can have multiple DVDs. I'm going to be looking at how CakePHP deals with this type of association and how to manually create these associations when saving related data.

0 comments Read More

Full CakePHP 1.2 App Part 4

9th May 2008 CakePHP
Full CakePHP 1.2 Application

As the title aptly suggests this is article 4 in my series of creating a full online DVD Catalog Application using CakePHP 1.2. Last time I quickly setup the Types and Locations Controller and Views so that I could start to add more data to the database.

In this article I'm going to create the DVDs controller and View files so that I can start to add / edit / delete DVDs from the database (I've gone for a Tarantino theme to begin with). This is going to be a bit more advanced because I am going to be uploading images to the server and I'm also going to use the jQuery Javascript library to progressively enhance a few forms and to stripe all the tables on the fly.

10 comments Read More

Full CakePHP 1.2 App Part 3

1st May 2008 CakePHP
CakePHP 1.2 Full Application

Welcome to the 3rd article in a series on creating a full CakePHP 1.2 Application. If your new and interested in the project then check out part 1 and part 2 to get fully up to speed on the application in question and see what I've done so far. Just quickly, last time I went through creating the Controller and Views for the Formats table in the database and at the end I could view / add / edit and delete formats using the application.

In this article I'm going to create the Controllers and Views for the Types and Locations. This is going to be pretty simple because they include the exact same functionality as the Formats that was created previously. At the end of the article I will be able to start adding even more data to the database and have a strong understanding of the way CakePHP deals with data.

0 comments Read More

Full CakePHP 1.2 App Part 2

24th April 2008 CakePHP
CakePHP 1.2 Full Application Image 1

This is the second article in the series on creating a full DVD Catalog online web application with CakePHP 1.2. Last time I went through the process of beginning a new application from scratch. I created a small brief which led to quite a few requirements that the application will need to do and from those requirements I came up with a database structure that should hold up throughout the project life cycle. Finally I sent up CakePHP on my local computer using Xampp with a Virtual Host and created the Model files for the application. If you have not yet read the first article then please go back and have a quick look so you (hopefully) know what I'm talking about.

In this article I'm going to focus on the Formats table of the application and this includes creating a controller to deal with the functionality that the application will offer such as adding, editing and deleting formats. As well as the controller I'm going to create the related views for all the Format actions and at the end of the article we will be able to start adding data to the application.

2 comments Read More

Full CakePHP 1.2 App Part 1

18th April 2008 CakePHP

This is the first article in a series that I will use to document the process of creating a fully featured web application in CakePHP. At the moment the whole series comes in at around 8 articles but I'm sure this will grow as I write up each one. My aim is to publish one article a week detailing the steps involved with setting up and coding a full working online DVD Catalog Application that will keep track of all my DVDs. I've been meaning to create such an application for a long time so I thought it would be a great project to put on my website.

In this first article I'm going to go through the steps of setting up your new CakePHP project, go through the requirements of the system, create the database structure and finally setup the Model's and associations. For this project I'm going to be using the newest 1.2 version of CakePHP, I haven't used it before so this will be a learning process for me as well. For this series of articles I'm going to try something different and offer the full source code for the application at a small fee, the small fee is a one time thing and you will receive the source code for all the articles along with the final application. Its a pretty good deal for the amount of time and work that I'm going to be putting in to the project but it's just an experiment at this stage.

3 comments Read More

Initial Thoughts on the Codeigniter PHP Framework

28th March 2008 CakePHP CodeIgniter
CodeIgniter Logo

For the past few weeks i have been working with the CodeIgniter framework for a large scale project at work, the system is a project management application that allows different levels of users to login and track projects that belong to them. My first experience of a PHP framework was the wonderful CakePHP and my exposure to that MVC framework helped me greatly when using CodeIgniter. In this article I'm going to go through a few pro's and con's of CodeIgniter coming entirely from a perspective of a CakePHP user.

2 comments Read More

Multiple Admin Levels in CakePHP

25th March 2008 CakePHP

Usually when building a website that has a content management system (CMS) you will need a control panel that will be accessed via a login page so that only administrators with a username and password can login and change the site. CakePHP comes equipped with "Admin Routing" that will automatically re route URLs such as http://cakephp/admin/posts/add to a controller action called admin_add this is extremely useful for admin panels.

The only drawback of using Admin Routing is that by default it can only accommodate a single admin user, recently I've been working on a project that requires multiple levels of users e.g. admins, members, and general visitors and I wanted a way of doing this in CakePHP. Luckily I found this solution in the bakery and I've slightly modified it to meet my needs.

3 comments Read More

Custom CakePHP Flash Messages

21st March 2008 CakePHP
custom flash messages in CakePHP

For a new project I'm working on I want to display custom error messages that are enclosed in a coloured box depending on the action, for example if a post was successfully saved i want to display a message inside a green box and if it failed i want to display the message in a red box.

Usually i just use the flash messages that are built into the Session helper, these messages are displayed on the next page after the controller has redirected the user. The major limitation of using setFlash() is that only a single message can be displayed, so when this message is displayed in the view there is no way of knowing whether it is a success or failure message. In this post i'm going to go through the process of creating your own helper which will display a custom flash message.

3 comments Read More

Form Validation in CakePHP

14th March 2008 CakePHP
Form Validation in CakePHP Image 1

Form Validation is an essential task in any online application, its also an incredibly dull, tedious and repetitive task but with CakePHP you can cut down the time and effort you spend validating your form data. In a standard PHP application you will normally display the form for user input, try to validate the data, if errors exist redisplay the form showing the errors whilst keeping the data that was already submitted and go through the process again until the data successfully validates.

In this article I'm going to through the basics of creating a Model, baking a sample application and explain how you can use CakePHP to automatically validate your data.

3 comments Read More

Using URL Slugs in a CakePHP App

7th March 2008 CakePHP
URL slugs in a CakePHP Blog Application

URL slugs are extremely common on the internet today, particularly on website blogs. The title of the post is used as an identifier in the URL instead of an id number, this makes it possible for a person looking at the URL to know what the post is generally about. For example this post in your address bar is seen as "/posts/view/using_url_slugs_in_a_cakephp_app" instead of "/posts/view/1" which makes the URL meaningful and human readable.

In this article I'm going to go through the benefits of using URL slugs and how to incorporate them into the CakePHP blog application that we have been building over the previous articles.

2 comments Read More

Uploading Files and Images with CakePHP

22nd February 2008 CakePHP

When starting out with CakePHP I found it to be a very steep learning curve, getting used to MVC along with learning all of CakePHP's magic methods was quite a lot of infomation to assimilate. Using a framework can sometimes lead you down the path of becoming a lazy programmer who expects everything to be done in an abstracted way and that was my thought process when dealing with file uploads. I expected CakePHP to do everything for me and for a time I was a little stuck on how to go about uploading and dealing with files.

Then stupidly I realised that Cake was a PHP framework and I could deal with file uploads like any other file upload I've been working with on normal web projects. In this article I'm going to continue our previous blog application by adding a file upload facility. Each post will now have the option of uploading an image which will be stored on the server and the url of that file will be stored in the database so we can easily access it when a post is viewed.

12 comments Read More

Adding Tags to a CakePHP App (hasAndBelongsToMany)

15th February 2008 CakePHP

In this article I’m going to concentrate on the ‘hasAndBelongsToMany’ (HABM) model association by integrating Tags to the Blog application that we have experimenting with. As you are probably aware Tags have become a popular method of organising posts and are really just categories. This type of relationship is different from the others you have been using because a single post can have multiple Tags and a single Tag can have multiple posts. This is different from the comments example that I looked at previously where a comment can only belong to a single Post.

As usual I suggest reading the models chapter of the online CakePHP manual, taking special attention to the ‘Defining and Querying with hasAndBelongsToMany’ section near the bottom. At first I had problems with choosing an association to use but this will come with practise and experience building different applications. If you’re having trouble just drop me an email and I’ll try to help you out.

3 comments Read More

Adding Comments to a CakePHP Blog App (hasMany, belongsTo)

8th February 2008 CakePHP

One of the most powerful features of CakePHP is the ability to handle model associations, at its very simplest an association occurs when some data in the database is related to some other data. In normal PHP applications you would normally have to write a custom SQL statement that will grab the data using a JOIN statement. Obviously this kind of custom query can be accomplished in CakePHP but it will automatically grab all the related data as long as you have specified the relationship in the Model file.

In a simple example i'm going to stick with the mandatory 'Blog Application' and add a comment system, so that people can assign comments to posts. Before starting I recommend reading the Associations section in the manual and my previous post about using the 'bake' script.

0 comments Read More

Creating an Admin Section with CakePHP

1st February 2008 CakePHP
Admin Section with CakePHP

With most database driven websites you will normally need an admin section that requires a username and password that will give you access to a control panel where you can add/edit/delete information. With CakePHP this is quite simple with the help of “admin routing”, in the blog tutorial we can access the posts via “http://cakephp/posts/” with admin routing we can separate out all admin functions by adding “http://cakephp/admin/posts/” to the URL.

In this post we are going to re-visit the blog tutorial and implement an admin section that will require a username and password. Any request to an admin specific action will result in a login page being shown if you are not logged in, we will also be using the “Bake” command line script so please go over my previous post if you don’t know how to use it.

17 comments Read More

Baking with CakePHP

25th January 2008 CakePHP
Bake Command Line in CakePHP

One of the many great things about CakePHP is the ability to use the inbuilt “bake” script that will automatically create all your controller and view files including all the source code. This is simply a great tool that will get your project up and running extremely quickly and will take away the monotony of building basic add/edit/delete actions in PHP. This article will begin by setting up everything you need to get “bake” working under windows and will then bake the blog application that was introduced in the CakePHP manual.

1 comment Read More

Opening CakePHP Files in Dreamweaver

21st January 2008 CakePHP

I primarily use Adobe Dreamweaver to create and code all of my websites, mainly because of the code highlighting and the way I organise my sites in separate folders. I realise that there are loads of text editors out there but Dreamweaver is what I’m comfortable with and it does the job.

When starting out with CakePHP I quickly found out that Dreamweaver doesn’t open .THTML and .CTP files automatically and I had to do a bit of hunting on the web to get the problem solved. The solution is pretty easy so this is just a quick post to get Dreamweaver opening .THTML and .CTP files.

22 comments Read More

Installing CakePHP

11th January 2008 CakePHP
CakePHP Image

Over the past few months I have been getting to grips with CakePHP, a rapid development framework written in PHP that uses the Model, View, Controller (MVC) software design pattern. If you are a PHP programmer then give this framework a try because quite frankly it’s the bee’s knees.

Although it does have quite a steep learning curve once you become familiar with the concepts it will help to improve your programming skills and will also get your database-driven websites up and running extremely quickly. This post is going to be the first of many regarding CakePHP and my plan is to release posts quite regularly that build upon the Blog tutorial found in the manual.

1 comment Read More

Back to Home Page

Recently Watched Films

Mr Brooks Rec Pathology Diary of the Dead

TV Shows

The Shield Flight of the Conchords

Site by James Fairhurst 2008, all rights reserved and all that malarky