TwitterCounter for @bigclick_dean

dBlog.com.au

My Development Blog

Archive for the ‘ CakePHP ’ Category

Lithium has finally been released!

Picture 4

I see you asking “What is Lithium and why have I never heard of it before!?!?”

The answer…Lithium is a fork (Cake3) of the popular CakePHP framework and was born out of a split in the CakePHP development team (mainly Lead Developer Nate Abele).

Lithium looks to rewrite the Core codebase and make use of some new PHP 5.3 features…like namespaces!!!

If you want to check out the project and have a play then head on over to http://li3.rad-dev.org/

Stay tuned for some of my initial impressions in a future post.

-Dean

Popularity: 1% [?]

Big Click Studios is a dynamic company based on the NSW Central Coast with a relaxing and innovative work environment.

Fantastic office just minutes from the beach and train station. You will be working on many of our current and upcoming web development projects all bursting at the seams begging for the right person to dig their teeth into!

Essentials:

  • PHP5 + MySQL
  • XHTML + Javascript (jQuery a bonus) & CSS
  • An eye for well structured code and clean database structures
  • Understanding of Object Orientated Programming

Bonuses:

  • CakePHP framework
  • AJAX
  • Flash / Actionscript 2 & 3

Personal characteristics:

  • Must be able to work as part of a team
  • Proactive involvement in the business (we work closely with all staff to provide a safe, fun and mentally challenging environment)
  • Strong communication skills (both written and spoken)
  • Xbox skills are not required but highly desired if you dont want to get whooped at lunch!

For more information please send an email to jobs@bigclick.com.au or give us a call on 1300 677 924.

Look forward to hearing from you soon!

Popularity: 1% [?]

I use CakePHP on a day to day basis for project ranging from a single controller with a couple of views through to projects with large amounts of Controllers, Models, Views and Relationships.

This morning I was trying to build a simple Google Analytics component (which I will release as soon as it is done) and I needed to use the Session component…easy enough I hear you say…WRONG! I sat there for over an hour trying to figure out why my session was clearing every time I refreshed.

I searched high and low to find a solution, I tested the PHP session configuration by turning off “Session.start” in core.php and using the php “session_start()” function instead, everything worked fine.

After pulling out all my hair (what was left of it), I started thinking that it could be something to do with something being output before the header. I wasn’t getting any “Header Already Sent” warnings but I was still skeptical.

BINGO! I removed a single space after the closing php tag in one of my controllers and everything started working again.

It was so simple yet I have seem multiple threads on forums with the same problem but with no posted solution, hence why I am posting this for future reference (and when I inevitably forget).

So when troubleshooting CakePHP sessions make sure the first thing you do is remove any excess whitespace from your controllers, models and components.

A simple space after the ?> tag can cause all sorts of weird Session behaviour.

Popularity: 1% [?]

Why did I do it?

While working on a client project I needed a way to heavily integrate with Twitter for an interactive competition. I could have built a quick and dirty script to do this but I knew that I would be dealing with more clients that wanted Twitter integration.

What did I do?

I built a CakePHP Component to access all the Twitter API features along with the Twitter Search API for Searching/Trending.

There are already some Twitter API components for CakePHP but they all had their own little bits that I didn’t like so I decided to whip one up and share it for everyone to use.

As the component is 1140 lines I wont be posting it here in the article, but you can view the source code here.

How does it all work?

There is nothing like a fully functioning example to show you how to use it! So I have built a quick replica of the Twitter homepage to give you a feel for it.

View the example first to see what we will be building, it is updated every refresh and everything is pulled straight from Twitter’s API.

First up you will need to put the Twitter Component into your /app/controllers/components/ folder and call it twitter.php, you can find the text version here or download the source files at the bottom of the page.

Now create a new controller called twitter_controller.php and put the following content into it. Don’t forget to change the {USERNAME} and {PASSWORD} place holders to your Twitter details.

<?php
/**
* Twitter Controller
*
* This class is used to manage twitter communication
*
* @version 0.1
* @author Dean Collins <dean@bigclick.com.au>
* @project dblog
*/
class TwitterController extends AppController {
	/**
	* Controller Name
	* @access public
	* @var string
	*/
	var $name = 'Twitter';

	/**
	* Components that are used in this controller
	* @access public
	* @var array
	*/
	var $components = array('Twitter');

	/**
	* Models that are used in this controller
	* @access public
	* @var array
	*/
  	var $uses = array();

	/**
	* Helpers
	* @access public
	* @var array
	*/
  	var $helpers = array('Text', 'Html');

	/**
	* Default action
	*
	* The index function is used as a default action, in this case it will replicate your twitter page
	*/
	function index() {
		$this->layout = 'twitter';
		$this->Twitter->username = '{USERNAME}';
        $this->Twitter->password = '{PASSWORD}';
		// Grab the recent activity
		$feed = $this->Twitter->statuses_friends_timeline();
		// Grab the users details
		$user_details = $this->Twitter->account_verify_credentials();
		// Get your friends
		$friends = $this->Twitter->statuses_friends();
		// Get your followers
		$followers = $this->Twitter->statuses_followers();

		$this->set('feed', $feed);
		$this->set('user_details', $user_details);
		$this->set('friends', $friends);
		$this->set('followers', $followers);
	}

}
?>

Now create a new layout in your /app/views/layouts/ called twitter.ctp and put the following content in:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CakePHP/Twitter API Example</title>
<style type="text/css">
/* v1.0 | 20080212 */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-size: 100%;
	vertical-align: baseline;
	background: transparent;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}

/* remember to define focus styles! */
:focus {
	outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
	text-decoration: none;
}
del {
	text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
	border-collapse: collapse;
	border-spacing: 0;
}

</style>
</head>

<body>
<div style="top: 0px; left: 0px; width: 100%; height: 45px; padding-top: 20px; margin-bottom: 10px;">
	<div style="width: 800px; margin: 0 auto;">
    <h1 style="font-size: 24px;">CakePHP Twitter API Class Example</h1>
    </div>
</div>
<?php echo $content_for_layout; ?>
</body>
</html>

Finally create a new view under /app/views/twitter/ called index.ctp and put the following content in:

<style type="text/css">
body { font-size: 12px; font-family:Arial, Helvetica, sans-serif; background-image: url('<?php echo $user_details['User']['profile_background_image_url']; ?>'); background-attachment: fixed; background-repeat: no-repeat; }
.status_update img, .avatar { float: left; width: 48px; height: 48px; margin-right: 10px; }
.status_update { overflow: hidden; color: #333333; font-size: 12px; padding: 5px; border-bottom: 1px dashed #333; }

.status_update:hover { background-color: #CFF }

a {color: #0084B4;}
#lcol { width: 600px; border-right: 1px solid #333; float:left; }
#rcol { width: 180px; padding: 10px; float:left;}
#wrapper {width: 801px; margin: 0 auto; border: 1px solid #333; overflow: hidden; background-color: #FFFFFF}

#user_stats { margin-left: 15px; overflow: hidden; }

#user_stats a { color: #333333; display: block; float: left; font-size: 20px; text-align:center; text-decoration:none; background-color: transparent;}

#user_stats a span { font-size: 12px; color: #0084B4; }

#profile_title { font-size: 18px; margin-bottom: 10px; overflow: hidden; }

.avatar_small { width: 24px; height: 24px; }

.avatar_list { list-style: none; list-style-type:none; overflow: hidden }

.avatar_list li { float: left; }

#rcol h2 { font-size: 18px; padding: 5px; margin-bottom: 5px; margin-top: 10px; }
</style>
<div id="wrapper">
<div id="lcol">
    <ol>
    <?php foreach($feed['Statuses']['Status'] as $status) { ?>
    <li class="status_update">
    <img src="<?php echo $status['User']['profile_image_url']; ?>">
    <p><?php echo $status['text']; ?></p>
    </li>
    <?php } ?>
    </ol>
</div>
<div id="rcol" style="background-color: #<?php echo $user_details['User']['profile_sidebar_fill_color']; ?>">
    <div id="profile_title">
        <img class="avatar" src="<?php echo $user_details['User']['profile_image_url']; ?>"/>
        <?php echo $user_details['User']['screen_name']; ?>
   	</div>
    <strong>Name</strong> <?php echo $user_details['User']['name']; ?><br/>
    <strong>Location</strong> <?php echo $user_details['User']['location']; ?><br/>
    <strong>Web</strong> <a href="<?php echo $user_details['User']['url']; ?>"><?php echo $text->truncate($user_details['User']['url'], 20, '...'); ?></a><br/>
    <strong>Bio</strong> <?php echo $user_details['User']['description']; ?><br/>
    <div id="user_stats">
        <a href=""><?php echo $user_details['User']['friends_count']; ?><br/><span>following</span></a>
        <a href="" style="margin-left: 20px;"><?php echo $user_details['User']['followers_count']; ?><br/><span>followers</span></a>
    </div>
    <h2>Followers</h2>
    <ul class="avatar_list">
    	<?php foreach($followers['Users']['User'] as $follower) { ?>
        	<li><a href="http://www.twitter.com/<?php echo $follower['screen_name']; ?>/" target="_blank"><img alt="<?php echo $follower['screen_name']; ?>" width="24" height="24" class="avatar_small" src="<?php echo $follower['profile_image_url']; ?>"/></a></li>
        <?php } ?>
    </ul>

    <h2>Following</h2>
    <ul class="avatar_list">
    	<?php foreach($friends['Users']['User'] as $follower) { ?>
        	<li><a href="http://www.twitter.com/<?php echo $follower['screen_name']; ?>/" target="_blank"><img alt="<?php echo $follower['screen_name']; ?>" width="24" height="24" class="avatar_small" src="<?php echo $follower['profile_image_url']; ?>"/></a></li>
        <?php } ?>
    </ul>
</div>
</div>

And that’s it! You can head to http://yourcakeinstall.com/twitter and you should see a Twitter-like page with all your details with friends, followers, tweets, etc.

You can see my example over here

There is ALOT you can do with the data from Twitter so please let me know if you build something using this component and I will chuck a link up here for you.

Download the Source Files

You can download the source files, including the above example below.

CakePHP/Twitter API Component Download

Don’t forget to follow me on twitter and subscribe to my RSS to stay in the loop.

Popularity: 1% [?]

TDG Building came to Big Click Studios needing a new and fresh corporate identity and a website to promote their business on the Central Coast.

We started from scratch by creating a friendly/fun corporate identity encompassing different themes from within the industry (Technical Drawing, related colours, etc). Once we had our ideas down we continued to create a layout for the website along with a full stationary pack and designs for their work vehicle.

The client requested that they be able to update the content on the site and they also wanted to be able to easily add/edit projects that they had completed and also the ability to add a randomized testimonial section. As the client was coming from a non-technical background we had to ensure that the processes were easy to follow and that they were fail proof.

Our custom in-house CMS sat behind the website with ease and it allowed the client to easily manage their site and content while allowing us to offer an affordable solution with ease of maintenance for us.

In the end we delivered a complete corporate identity at an affordable price and the client had this to say:

“Karen and I would like to thank Big Click Studios for all their efforts in creating the website for TDG Building, we are extremely happy with the outcome.

Justin & Dean went the extra mile when asked to assist us with the design work for our business logo, office stationary and signage for the company ute, we gave the guys our ideas and requests for the designs and they were executed perfectly without delay. We also found the guys to be very helpful and patient with us considering that we were not very computer savvy when it came to website & design work!

We wanted to lift the profile of TDG Building and we feel that we have accomplished this through the assistance of Big Click Studios.

Many Thanks,

Troy & Karen Gruden
TDG Building. “

Here are some photos of the finished ute:

TDG Ute 1TDG Ute 2

Another happy customer!

Popularity: 1% [?]

Whilst trekking around the wilderness learning the ins and outs of CakePHP I have compiled a list of helpful CakePHP related sites that have gotten me through some tough times.

After spending so much time finding these resources I thought that I would compile them into a list and publish them.

CakePHP.org

1. Official CakePHP website: The number one source for CakePHP manuals, blogs, API’s, articles and tutorials.

Donutczar.com

2. Donutczar.com: Great information and examples on Helpers in CakePHP 1.2, a really good source for people who want a hand’s on and visual explanation.

Cakebaker

3. cakebaker.42dh.com: Always has new and brilliant ideas for CakePHP applications and offers easy to understand and user-friendly tutorials.

ThinkingPHP

4. ThinkingPHP: Although ThinkingPHP is an all-round PHP information site it also has a very helpful and detailed area dedicated to CakePHP. ThinkingPHP also monitors other popular CakePHP blogs and provides all the information in a common and easy to manage area.

RosSoft

5. Rolsoft.wordpress.com: The RolSoft Blog is an oldie, but a goodie! It has articles on integrating AJAX, speeding up SQL queries in CakePHP and much more. Most of the content is outdated, but it still serves to point people in the right direction and to offer food for thought.

RolSoft

6. Mariano Iglesias: Not only does this blog look amazing, it has buckets of information, everything from CakeFest information, CakePHP tips, framework write-ups and more. This is a a site that you will want to add to your favourites and your blog reader!

Google Group

7. CakePHP Google Group: This is the official Google Code group for CakePHP and it has a large memberbase and has lots of information available. Sometimes it can be a little unwielding to find your way around, but once you have the hang of it you will be flying around in no time.

Tim Trice

8. Tim Trice: This is a great blog that concentrates on articles aimed at the CakePHP beginner. With articles ranging from “What CakePHP can do” through to extending the CakePHP Blog tutorial.

CakePHP.nu

9. CakePHP.nu: Another little CakePHP blog that had a couple of articles that really stood out to me. It is relativly new so there isn’t a great deal of content, but its more like quality over quantity.

In the Kitchen with CakePHP

10. In the Kitchen with CakePHP: This isn’t really a “site” as such but I thought it was worth a mention. “In the Kitchen with CakePHP” is a great tutorial for beginners who need a start to finish walkthrough of CakePHP and its features, it is also useful to have a read before selecting CakePHP as your framework of choice as it goes over many of the key features.

Well for now thats my 10 Helpful resources that got me out of some trouble, if you have any suggestions or comments then please feel free to post them below.

Popularity: 1% [?]