andrw.net
  • Home
  • Code
  • Work
  • About
  • Contact
  • Subscribe
CakePHP Toronto Meetup
thumb

Tonight we held Toronto's first CakePHP meetup (or so we think). I did a talk on RESTful web development with CakePHP and demoed building a RESTful application with CakePHP and consuming the REST...

Read More...

Auto Create Slugs in Croogo with jQuery

0 Comments
Posted by Andrew on November 22nd 2009, 11:55pm

I got tired of hand writing slugs for my blog posts, I am used to using the acts_as_sluggable behavior. I thought about implementing the behavior into Croogo but realized this might be better implemented as some simple Javascript. Initially I wrote a simple find and replace function with Javascript that converted spaces to hyphens but realized it didn't take into account special characters or more than one space so I did a quick search on Google and came across the jQuery Slug Plugin. It took me about 2 minutes to download and implement.

All you need to do is download the plugin and place it into your webroot/js directory and then modify a few lines in app/views/nodes/admin_add.ctp. The changes I made are below.

$javascript->link(array('nodes', 'jquery.slug'), false);

Include the jQuery slug plugin at the top of the page.

<script type="text/javascript">
$(document).ready(function(){
$("#title").slug({
slug:'permalink',
});
});
</script>

Set up the plugin and let it know the title field's ID and the class of the slug field.

echo $form->input('title', array('id' => 'title'));
echo $form->input('slug', array('class' => 'permalink'));

Add an ID to the title field and a classname to the slug field. That's about it, hope this saves you some time when you are writing your next article.

Bookmark and Share
Tags: • javascript • croogo • tutorial • development
Posted in Croogo | Leave a comment

Using CakePHP and RPX for Social Authentication

4 Comments
Posted by Andrew on November 21st 2009, 10:24pm

I am working on a social network application where I want to allow users to import their information from another social network or service that provides an open authentication. I looked at Facebook connect and Twitter sign on but after doing research the easiest solution for me was using RPX's hosted solution. It took me about 10 minutes to implement and maybe another hour to fine tune to my needs.

To start you will need to register with RPX and then set up your widget. Some of the providers (such as Facebook and Twitter) need you to set up the application on their network first and then they will provide you with an API key that you can then plug into RPX.

After setting up the widget they will provide you with some code to copy and paste, there really isn't any modifications needed to the code except setting the token_url which is used as a redirect url once the user has been authenticated. You will probably want to set the token_url to a registration page where the user can enter a username and password for CakePHP's authentication component.

Once you have everything in place you will need to set up some code for the action that corresponds with the token_url. First you will need to receive the token from RPX used to retrieve the user's data, then you will need to request the user's info using their API. Here is the code that I am using in my action.

App::import('Core', 'HttpSocket');
$http = new HttpSocket();

$token = $this->params['form']['token'];
$results = $http->post(
'https://rpxnow.com/api/v2/auth_info',
array(
'token' => $token,
'apiKey' => 'YOUR-API-KEY-HERE'
)
);
$user = json_decode($results);

I am using CakePHP's built in HttpSocket class to request the user's information. The information sent from RPX is in JSON format so I used PHP 5's built in json_decode method to create an object out of the json. Now you would most likely create a new user record and save the information received from RPX and in the view display a form to collect the rest of the user's credentials such as username and password.

That's it, it's very simple to use. If you have any questions leave a comment and I will get back to you as soon as possible.

Bookmark and Share
Tags: • tutorial • cakephp • development
Posted in CakePHP | 4 Comments

Recent Site Updates

2 Comments
Posted by Andrew on November 19th 2009, 7:06pm

I have been busy at work implementing new features into the site. Croogo is an amazing piece of software for anyone who knows a little CakePHP. It gives you the CMS as a base and let's you extend to your hearts content, something I was never really able to do with Wordpress. Below is a list of features that I have implemented.

  • Featured post on home page
  • Full text search for blog articles
  • Tag cloud
  • Archives for blog articles
  • Possibly related posts for blog articles

If anyone is interested in the code for the features not already documented let me know and I will write up a blog post. Stay tuned I will be releasing my second Croogo theme soon.

Bookmark and Share
Tags: • development • news • croogo
Posted in Site News | 2 Comments

CakePHP Video Encoder Component Released

0 Comments
Posted by Andrew on November 18th 2009, 7:29pm

I have just released my Video Encoder component for CakePHP. This will be handy for all of you trying to build the next YouTube with CakePHP. Check out the project page for instructions on how to use and to download. Also if you have any questions, comments or find any bugs leave a comment on the project page.

CakePHP Video Encoder Component

Bookmark and Share
Tags: • development • cakephp
Posted in CakePHP | Leave a comment

Mozilla Moves from CakePHP to Django

0 Comments
Posted by Andrew on November 17th 2009, 9:22pm

Mozilla recently announced that they are switching from CakePHP to Django. They are currently using CakePHP 1.1 and most of the reasons for the switch they list have been fixed in recent versions of CakePHP (1.2 & 1.3) such as debugging, unit testing and caching. I don't understand why they just didn't upgrade or at least take a look at the recent versions of CakePHP before switching and at least acknowledge the fact that most of the problems they had, had already been solved.

Mozilla moves from CakePHP to Django

It's sad to see the largest CakePHP property switch to another framework, but being the large company that they are I'm sure there was a lot of thought that went into the decision. Good luck in the transition.

Source: http://micropipes.com/blog/2009/11/17/amo-development-changes-in-2010/

Bookmark and Share
Tags: • django • mozilla • news • cakephp • development
Posted in CakePHP | Leave a comment
1 | 2 | 3 | 4 | 5

Tweet, Tweet, Tweet

Please wait while my tweets load  

Follow @andruu on Twitter.

Tags

design   development   cakephp   news   tutorial   hong kong   icons   iphone   croogo   themes   mozilla   django   javascript   plugin  

Categories

  • CakePHP
  • Croogo
  • Design
  • Site News
  • Themes
  • Travel
  • Uncategorized

Archives

  • October 2011
  • November 2010
  • September 2010
  • January 2010
  • December 2009
  • November 2009

Affiliate Marketing Made Easy

Blogroll

  • CakePHP
  • Croogo
  • Matt Curry
  • Debuggable
  • Mark Story
  • Miles Johnson
  • Fahad Ibnay Heylaal

Meta

  • Site Admin
  • Entries (RSS)
  • Comments (RSS)
Copyright © 2012 Andrew Weir, All Rights Reserved.
Powered by Croogo, Built with CakePHP.