Churro Wordpress Plugin - Rating, Reviews, Demo & Download
Plugin Description
Churro is a plugin that allows developers to easily create pages and functionality, in a style similar to CodeIgniter. By itself, Churro will not add any functionality to your WordPress site.
Tested with WordPress and WordPress MU 2.8.0 ~ 3.0.5
Requires PHP 5. PHP 4 is like 10 years old, you know?
Churro Basics
= URLs =
Churro requires friendly urls rather than query strings. Your url will usually be mapped as following: yoursite.com/class/method/variables
Controllers
The controller will be directly mapped to a file and class with the same name. For example,
yoursite.com/contact
will look for a file named contact.php in the /churro/ directory. This file should have a class contact that extends Churro. Without a defined method, it will default to index. All methods accessible through URLs will have ‘Action’ appended to it. The following code will provide scaffolding for yoursite.com/contact
and yoursite.com/contact/submit
<?php
class contact extends Churro {
public function indexAction(){
}
public function submitAction(){
}
}
Models
Churro gives you access to several important WordPress Models through the $this
keyword. The $wp
, $wpdb
, and $wp_query
classes, as well as $blog_id
in MU are all availble without using the global keyword, eg $this->wpdb
.
Views
Your views belong in your normal theme directory. If you are using multiple themes, you can override the direcotry using $this->Theme( 'directory-name' )
any place in the controller. To specify a view to use, $this->View( 'file-name' )
. Seperating logic from views is the most important thing to remember in Churro. To set varaibles in your view, use $this->vars->var_name
in the controller, and $var_name
in your view.
Ajax / Javascript
If you use the excellent jQuery javascript library, Churro will detect ajax requests and automatically return JSON. Churro defines a constant ISAJAX
on each request. With a little planning, it is very easy to create a dynamic application in a way that is totally accessible without javascript.
Learning Churro
There is much more functionality in Churro than outlined here. As of September 2, 2009, there is no complete, formal, documentation for writing code with Churro. Stay tuned to Substance Labs for tutorials.