Full CakePHP 1.2 App Part 12
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.
Genre Filter Problem
When filtering DVDs by Genre there is a display error with only a few DVD covers being displayed per shelf. On further inspection the problem occurs because when the Genre filter is active I have to manually remove the DVDs that don't match. To display 8 DVDs per shelf I use the index of the array to determine the current position and because I've manually removed DVDs from the array the index has been messed up.
To fix this I've added a simple counter in the /app/views/dvds/index.ctp so instead of using the array key index I'm going to use the counter instead. The changed lines are below to you just need to do a quick copy and paste.
// file: app/views/dvds/index.ctp <?php // check $dvds variable exists and is not empty if(isset($dvds) && !empty($dvds)) : // init dvd count $count = 1; ?> <div class="shelf"> <?php foreach($dvds as $key=>$dvd): ?> <?php // calculate if this dvd is the last on the shelf // if dvd number can be divided by 8 with no remainders $last_dvd = ( (($count) % 8 == 0)? 'dvd-last' : '' ); ?>
Image Upload Problem
When uploading images that already exist there are spaces in the new name that throws up some validation errors when viewing. This is a simple fix by removing the spaces from the new filename like so:
// file: app/app_controller.php // from $url = $rel_url.'/'.$now.' - '.$filename; // to $url = $rel_url.'/'.$now.'-'.$filename;
Integrating the new Image Resize Class
Recently I created an Image Resize class that will resize images on the fly and save a cached version on disk so save processing time next time the image is requested.
I copied the images_controller.php file from that post and pasted it into the controllers directory. I also created a new cache folder located at /app/webroot/img/cache to hold all the processed images.
Below is a quick change to the index.ctp so utilise the Image Resize Class. I wont go through all the steps here to get up and running with is so check out my previous article if your interested.
// file: app/views/dvds/index.ctp <!-- <img src="/<?php echo $dvd['Dvd']['image']; ?>" alt="DVD Image: <?php echo $dvd['Dvd']['name'] ?>" width="100" height="150" /> --> <img src="/images/view/100/150/true/<?php echo $dvd['Dvd']['image']; ?>" alt="DVD Image: <?php echo $dvd['Dvd']['name'] ?>" width="100" height="150" />
Single DVD View
The view single DVD page is quite simple and will display the full details of the DVD along with the cover image. Not much has changed in the actual view.ctp file except that a new layout has been created and the page has been styled with CSS.
Single Genre View
The view single Genre page displays the DVD covers on the shelf like the main index page and includes a title to display what Genre is being displayed. The new layout has been used so that the header can be displayed without the form.
Wow I've finally managed to wrap up most of the loose ends and the application is looking fairly complete, looking back I didn't think so time and effort would have gone into building an application like this but documenting every step is quite time consuming but hopefully its all been worth it.
Here a are few proposed improvements and features that I've not got round to implementing but they may get done in the future:
- Template system to change the look of the front end from the admin panel
- Amazon Lookup: When inputting a DVD automatically retreive data from Amazon
- A sprinkle of Ajax to make everything run a little more smoothly
Posted on 5th September 2008
8 years, 8 months, 2 weeks, 6 days ago