Monthly Archives: March 2009

How to deal with stress at work

I’m assuming I’m not alone with this one, but on a daily basis I seem to bring home a lot of stress from work.  At one point I use to bring home so much stress that I was unable to sleep at night.  From time-to-time it still happens, but with these techniques below I have been able to significantly improve the amount of stress I bring home from work.

Before we discuss resolutions, let’s discuss the type of stress us web developers/project managers bring home on a daily basis.

  • Angry clients
  • Your team members not performing well
  • A mistake by you
  • A bug that you were unable to find
  • Too much work
  • Mean boss
  • Difficult co-workers

I’m sure this list could carry on a lot longer, but I think we get the point with HOW much stress we can bring home on a daily basis.

Let’s begin by breaking each one down. Read more »

Share

When to use element() and when to requestAction()

Several times a week it seems, someone at my office is asking, “Jamie, should I use $this->element() or $this->requestAction()?”

Every time they ask, I ask them back, “What do you need to do?”

There are a few simple ways to determine if using an element is better or a request action is better. Read more »

Share

CakePHP Containable Statement Pitfalls

On some of our more recent projects, we have been using the Containable behavior that CakePHP provides.  It works quite nicely, a lot easier than the previous format of having to bind and unbind models on the fly.

The pitfalls began to appear when some of our clients were reporting that some pages are extremely slow.  After a bit of research, it was quite apparent that the root of the cause was attributed to us using the containable feature. Read more »

Share

Keeping your CakePHP Controllers Clean

As my office gains more and more experience with CakePHP, we are beginning to learn to build more organized web sites.  Looking back at our first few projects, I’m astonished to see how messy our controllers are!

I know the controllers are the “brain” of MVC because it pieces our data to our views, but that doesn’t mean everything should go in there.  Our original controllers would contain all of our logic, all of our data manipulation, all of our custom queries, and some additional data validation.

We are now working very hard to keep our controllers as clean and simple as possible.  My goal is to make every function in our controllers under 20 lines of code.  It might sound ambitious, but I think it is completely feasable. Read more »

Share

Underscores and Internet Explorer Fun

I think my favorite thing about being a web developer is wasting hours and hours of my time, my co-workers time, pretty much every ones time because Internet Explorer is retarded.

Earlier this week, we were developing a site and we created a new sub domain off of our main domain.  Because we already had an existing sub domain for the same client, the team decided to postfix the sub domain with _new.  When we started testing our work, it didn’t start off well.  Open up Internet Explorer 7 and receive the login page, attempt to login and just get redirected back to the login page.

We know there is nothing wrong with our login script as it works fine in Mozilla and it’s something that we’ve used on a million other projects.

My head still hurts from banging it against the wall for quite some time to simply discover that Internet Explorer rejects session cookies when a domain contains an underscore (“_”) in the name!

I know this is the shortest article I’ve ever written, but I had to vent.  Hopefully if you run into this problem you will Google it sooner than we did and this article will save you time and a headache!

Share

Drag and drop category management with CakePHP

Today’s article is going to walk you through creating a slick drag and drop with AJAX category management system.

CakePHP offers a really nice built-in tree management.  In fact, at a bare minimum you simply need to create a table with 2 extra columns, tell your model to act like a “tree” and rather than doing a find(‘all’) you do a generatetreelist() or a find(‘threaded’) and CakePHP takes care of the rest.

After doing a quick test, I was quite impressed with what CakePHP did for me, but I was not satisified.  I wanted to create a really slick category management system that I can re-use and show off.  Well, in this tutorial I go about 90% of the way.  The only thing I didn’t have time to finish was, rather than redrawing my tree through AJAX, use DHTML and dynamically update my tree after dragging and dropping.  Don’t worry, I plan to finish this with a part two soon. Read more »

Share

Drag and drop with animations in jquery

Every year at Halloween, my company offers prizes to the best dressed employees.  For the past two years I have one as well as my co-worker that partakes in our crazy costumes.  You may be wondering what this has to do with drag and drop, don’t worry I’m getting there.

This years prize happened to be a monkey slingshot.  Basically you place your index and middle fingers in pockets attached to the monkey’s arms.  You then proceed to pull back and let fly.  Well, as you can imagine, we had a lot of fun with this guy, so much fun in fact we broke it :(

So one day after work I was messing around with drag and drop and some jquery animations.  I was quickly able to get a “mock slingshot” shooting at a target and this is what I want to share today. Read more »

Share

How to add comments with AJAX in CakePHP

In today’s article we are going to create a very basic blog that allows people to create a post and posts comments on that post via AJAX.  We are going to keep it extremely basic and just focus on that actual AJAX functionality.

Ready? Let’s begin.  We are going to start by creating two database tables: posts and posts_comments.  Below is a sample create statement for the posts table: Read more »

Share

How to advance our CMS in CakePHP

At the end of part one, we had a working CMS.  Well, at least it was saving files and they could be displayed to the public.  In today’s article, we are going to further advance our CMS.  We will cover the following items:

  1. fckEditor
  2. Revisions

Read more »

Share

How to create a CMS with CakePHP

I really enjoying writing code and I find that snippets just don’t always cut it for me.  So in today’s article, I am going to describe the process of creating a CMS (Content Management System) with CakePHP.

This will be a two part article, in part one we will focus on getting the basics working.  The basics will include ability to add, edit, and delete static content pages.

Part two will advance on our basis and allow us to create drafts and revert back to previous versions.

To begin, let’s download the latest release of CakePHP.  After you’ve downloaded it, extract it to a folder of your choice.  In my case it will be c:\xampplite\htdocs\CMS.  I can now access my new web site by browsing to http://localhost/CMS. Read more »

Share

Buy one of my books