Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created May 13, 2009 10:19
Show Gist options
  • Save speedmax/110961 to your computer and use it in GitHub Desktop.
Save speedmax/110961 to your computer and use it in GitHub Desktop.
{{ 'Edit' | link_to_edit page }}
{{ 'Show me some love' | link_to_view page }}
{{ 'Delete them all' | link_to_delete page }}
<?php
/*
Recently i have been ask about Framework integration with h2o, particularly CakePHP and Zend
compare to rails restful named routes, full routes in php is so so painful,
If you build a thin template object layer, it will work even better
*/
H2o::addFilter('link_to_(.*)', 'link_to_dynamic');
function link_to_dynamic($type, $object, $args) {
$class = current(array_keys($object)));
return Router::url(array(
'controllers' => Inflector::pluralize($class),
'action' => $type,
'id' => $object[$class]['id']
));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment