Amazing 3D artwork
July 26, 2010 by Adam · Leave a Comment
http://www.radoxist.com/artworks/56
The detail on these images is amazing, check it out
The best blog article I’ve read in a long time (and I found it totally accidentally)
July 23, 2010 by Adam · Leave a Comment
http://retinart.net/graphic-design/secret-law-of-page-harmony
and following on from that:
http://51elliot.blogspot.com/2009/12/canons-of-layout.html
Well worth taking 30 minutes to properly read both of these.
p.s. I’m writing this on a monitor which is 1440 by 900, guess what 1440/900 is
Good resource for MySQL table types…
March 3, 2010 by Adam · Leave a Comment
http://www.softwareprojects.com/resources/programming/t-mysql-storage-engines-1470.html
Pet Peeve…
March 1, 2010 by Adam · Leave a Comment
It’s never, ever, ever “an HTML”. It’s always always always “a HTML”. Read it out loud. “a haych-tee-em-el document” or “a hyper-text markup language document”. The rule is simple. If it sounds like it starts with a vowel, use an, otherwise, it’s a.
If you can’t get your head around this, put an x infront of it “an xHTML document” or “an ex-haych-tee-em-el document”. I’ll stop yelling at you then.
Easy Multi Page Forms (or Wizards) with CakePHP
February 16, 2010 by Adam · Leave a Comment
There is a wizard component available for CakePHP that’s been around for a very long time, however it uses a lot of code to something that doesn’t really need it. Today I needed to spread a single form across multiple pages for an app I am writing.
Here is the very simple controller action I used to achieve it:
<?php
function add($step = 'account') { // $step is your first page
$order = array(
'contact_name' => $this->Auth->user('contact_name'),
'company_name' => $this->Auth->user('company_name'),
'account_number' => $this->Auth->user('account_number'),
'delivery_address' => $this->Auth->user('delivery_address'),
'invoice_address' => $this->Auth->user('invoice_address'),
'promotional_discount' => $this->Auth->user('promotional_discount'),
'extra_ordinary_discount' => $this->Auth->user('extra_ordinary_discount')
); // your defaults
if($this->Session->check('order')) {
$order = Set::merge($order, $this->Session->read('order'));
}
if(!empty($this->data)) {
$this->data['Order'] = Set::merge($order, $this->data['Order']);
if($step == 'thanks') { // $step is your last step
if(!$this->Order->save($this->data)) {
$this->Session->setFlash('There was an error trying to save your order,
please make sure you completed all steps');
$step = 'confirm'; // $step is your last-but-one step
}
}
} else {
$this->data['Order'] = $order;
}
$this->Session->write('order', $this->data['Order']);
$this->render('add' . DS . $step); //put your files in a folder and name them after the matching step, no need for validation, cakephp will 404 on any missing steps
}
?>
Then in your view, post your form to the next page, so the accounts page posts to /orders/add/range, the range form posts to /orders/add/items and so on. You can then provide user navigation between the steps just by linking to that page.
<div id="page" class="accountinfo">
<?php
echo $this->Form->create('Order', array('url' => '/orders/add/range'));
echo $this->Form->input('contact_name');
echo $this->Form->input('company_name');
echo $this->Form->input('account_number');
echo $this->Form->input('order_number');
echo $this->Form->input('date_required');
?>
<div id="paging">
<?php echo $this->Html->link('Previous', array('controller' => 'orders', 'action' => 'index')); // first step so previous takes you back to the index ?>
<?php echo $this->Form->submit('Next'); ?>
</div>
<?php echo $this->Form->end(); ?>
</div> <!-- page -->
I don’t think I could make this any simpler!