neillyons.infoonline blog of web developer neil lyonshttp://neillyons.info/KohanaPHPCodeIgniter 1.7 Professional Development book reviewhttp://neillyons.info/articles/codeigniter-17-professional-development-book-reviewhttp://neillyons.info/articles/codeigniter-17-professional-development-book-review<h2>Unfortunately it won't make you a CodeIgniter expert.</h2> <p>A couple weeks ago Packt publishing contacted me to review a book they had recently published, called <a href="http://www.packtpub.com/codeigniter-1-7-professional-development/book?utm_source=neillyons.info&utm_medium=bookrev&utm_content=blog&utm_campaign=mdb_003264">CodeIgniter 1.7 Professional Development</a> by Adam Griffiths.</p> <p>The preface states the book will take you "beyond the ... user guide and into more advanced subjects". It's not obvious what advanced subjects are covered. I assume the chapters "User Auth", "User Auth 2", "Building Large Scale Apps", "Web services" are what is referred to here, as these seem to be the only chapters not covered by CodeIgniter's user guide. With the exception of "Deploying and…Fri, 11 Jun 10 00:58:17 +0100Database driven routes in CodeIgniter with cachinghttp://neillyons.info/articles/database-driven-routes-in-codeigniter-with-cachinghttp://neillyons.info/articles/database-driven-routes-in-codeigniter-with-caching<h2>A faster, simpler and easier solution to database driven routes in CodeIgniter.</h2> <p>Don't know what I'm on about? Read my previous article on <a href="http://neillyons.info/articles/database-driven-routes-in-codeigniter">database driven routes</a>.</p> <p><span class="header">Prerequisites</span></p> <ul> <li><a href="http://codeigniter.com/">CodeIgniter</a></li> <li><a href="http://stensi.com/datamapper/">Datamapper</a></li> </ul> <p><span class="header">Step 1</span></p> <p>Define 3 new methods in your routes model (..system/application/models/route.php).</p> <pre><code>function save() { parent::save(); $this->cache(); } function delete() { parent::delete(); $this->cache(); } /** * Writes contents of database table to a cache file. * * @return void */ function cache() { $data[] = "<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');"; foreach($this->get()->all as $value) { $data[] = '$route["' . $value->route .…Tue, 04 May 10 23:58:37 +0100Django style comments module for Kohana 2.3http://neillyons.info/articles/django-style-comments-module-for-kohana-23http://neillyons.info/articles/django-style-comments-module-for-kohana-23<h2>The comments module allows you to quickly attach comments to models without creating extra tables or columns in your database.</h2> <p><span class="header">Download</span> <img src="http://neillyons.info/files/uploads/django_comments/comments%20module%20folder%20structure.jpg" alt="Kohana comments module folder structure" /> <a href="http://neillyons.info/files/uploads/django_comments/comment.zip" >comment.zip</a></p> <p><span class="header">Install</span></p> <p>Unzip and copy the folder to the Kohana modules directory. Then edit the modules array in your configuration file (application/config/config.php) to include the path to the comments folder.</p> <p>Your modules array should look similar to this.</p> <pre><code>$config['modules'] = array ( // MODPATH.'auth', // Authentication // MODPATH.'kodoc', // Self-generating documentation // MODPATH.'gmaps', // Google Maps integration // MODPATH.'archive', // Archive utility // MODPATH.'payment', // Online payments…Mon, 22 Feb 10 23:35:32 +0000Database driven routes in CodeIgniterhttp://neillyons.info/articles/database-driven-routes-in-codeigniterhttp://neillyons.info/articles/database-driven-routes-in-codeigniter<h2>Using a pre_system hook the routes array can be populated from your database.</h2> <p>A route is a CodeIgniter controller action alias. Used to build search engine friendly sites. eg posts/database-driven-routes-in-codeigniter is mapped to posts/get/2</p> <p><span class="header">Step 1</span></p> <p>Define the hook by inserting the code below into the hooks.php file ( ..system/application/config/hooks.php ).</p> <pre><code>require_once BASEPATH."application/config/database.php"; $hook['pre_system'] = array( 'class' => 'Router_Hook', 'function' => 'get_routes', 'filename' => 'Router_Hook.php', 'filepath' => 'hooks', 'params' => array( $db['default']['hostname'], $db['default']['username'], $db['default']['password'], $db['default']['database'], $db['default']['dbprefix'], ) ); </code></pre> <p>This is a pre system hook, which means it is called before any routing has occurred. This hook will call…Sun, 14 Feb 10 12:44:53 +0000Configure CodeIgniter to run on two servershttp://neillyons.info/articles/configure-codeigniter-to-run-on-two-servershttp://neillyons.info/articles/configure-codeigniter-to-run-on-two-servers<h2>Using a dynamicly defined constant in the index.php file, CodeIgniter can be set up to run on two servers.</h2> <p>I have found this really speeds up my development time, especially if used along with <a href="http://wiki.bazaar.canonical.com/BazaarUploadForWebDev">Bazaar Upload for Web</a>. With this feature, the same CodeIgniter installation can run on two servers without the need to change configuration variables.</p> <p><span class="header">Step 1</span></p> <p>To implement this feature into CodeIgniter, edit the index.php file, and include the following code at the top.</p> <pre><code>if ($_SERVER['SERVER_NAME'] == 'localhost') { //Development enviroment. define('SITE_LIVE', FALSE); } else { //Live enviroment. define('SITE_LIVE', TRUE); } </code></pre> <p>The code determines…Sat, 13 Feb 10 18:28:13 +0000