Skip to content

Instantly share code, notes, and snippets.

View cakephp-tutorial's full-sized avatar

CakePHP Italia Tutorial cakephp-tutorial

View GitHub Profile
<?php
Route::redirect('/articoli/*',
  'http://www.google.it',
  array('status' => 302)
);
<?php
Router::redirect('/articoli/:id',
array(
'controller' => 'posts',
'action' => 'view'
),
array(
'status' => 302,
'persist' => array('id'),
)
<?php
Router::connect('/blog/articoli/:id',
array(
'controller' => 'posts',
'action' => 'view'
),
array(
'id' => '[0-9]+',
'pass' => array('id')
)
<?php
echo $this->Html->link('Articolo 3', array('action' => 'posts',  'action' => 'view', 3, '?' => array('queryKey001' => 'queryValue001'), '#' => 'idAncora'));
<?php
$url = Router::url(array('controller' => 'posts', 'action' => 'view', 3));
<?php
$this->redirect(array('controller' => 'posts', 'action' => 'view', 3));
<?php echo $this->Html->link('Articolo 3', array('action' => 'posts',  'action' => 'view', 3 ));
<?php
Router::connect('/articoli/:id',
array(
'controller' => 'posts',
'action' => 'view'
),
array(
'id' => '[0-9]+',
'pass' => array('id')
)
<?php
$this->Customtime->timeLeft(date('2014-12-15 18:20:15'));
# 'Oggi alle 18:20'
$this->Customtime->timeLeft(date('2014-12-18 15:20:15'));
# 'Tra 3 giorni alle 15:20'
$this->Customtime->timeLeft(date('2014-12-21 08:20:15'));
# 'Tra 6 giorni alle 08:20'
<?php
echo $this->Customtime->timeAgo(date('2014-12-15 15:20:15'));
# '1 ora fa'
echo $this->Customtime->timeAgo(date('2014-12-15 08:20:15'));
# 'Oggi alle 08:20'
echo $this->Customtime->timeAgo(date('2014-11-14 20:20:15'));
# '14 Novembre'