Breadcrumb Helpers

From PHP on Trax

Jump to: navigation, search

A few handy convenience helper functions: (I use it for breadcrumbs)



<?php

// Link to home
function link_to_home($text 'Home') {
   return 
link_to($text, array(':controller' => ''));
}

// Link to the index action of the controller
function link_to_index($controller) {
   return 
link_to($controller, array(':action' => ''));
}

// Anchor link
function link_anchor($name) {
   return 
sprintf('<a name="%s"></a>'$name);
}

// Build the complete url based on your $url_prefix as set in your env. config
function build_url($url) {
   if(
is_array($url)) {
      return 
array_map('strtolower'$url);
   } else {
      return 
strtolower(Trax::$url_prefix $url);
   }
}

?>
Personal tools