Get it All
Together

I’m a big fan of Viper007Bond’s plugins, so when I saw he was releasing a new version of his SyntaxHighlighter, I had to give it a go. Especially for this website, it’s always been a challenge to find just the right code highlighter to properly display my code. What follows is an experiment with the new plugin, based on some CakePHP code I’ve been working on.

[php highlight=”6,29″]
<?php
class MetrosController extends AppController {

var $name = ‘Metros’;
var $helpers = array(‘Form’);
var $components = array(‘Uuid’, ‘Cookie’);
var $uses = array(‘Metro’, ‘Pothole’, ‘Town’);

// Cookies:
var $cookieName = ‘PHpatrol’;
var $cookieKey = ‘has82js737hak2’;
var $cookieDomain;
// Add domain name dynamically:
function __construct() {
parent::__construct();
$this->cookieDomain = ‘.’.$_SERVER[‘SERVER_NAME’];
}

function index()
{
$this->set(‘metros’, $this->Metro->find(‘all’));
print_r($this->Cookie->read());
}

function add()
{
if (!empty($this->data[‘Metro’]))
{
$this->data[‘Metro’][‘ID’] = $this->Uuid->generate();
if($this->Metro->save($this->data[‘Metro’]))
{
$this->flash(‘Your Metro has been updated.’,’/metros/’);
}
}
}
[/php]
Looks good! I’ve thrown some random highlighting in there just to see how it works.