Convenient $html->link()
I made this quick helper that extends Html Helper. While creating my very first plugin for cakephp 1.2, I decided to use Route so that I can save some space and time typing long controller names. Here is the sample code in my views:
I am a lazy typist and so I wanted to be able to use shortcut names for the array keys such as the following:
I couldn’t find in the bakery any solution so I decided to create my own Html helper. Here is how you can install it:
First, add this file to your helpers folder located in
Download XHTML Helper
Then, in your controller file, include the Xhtml to your helpers list. Example
That’s it. You can use it by doing the following:
OR
Take note of using xhtml instead of html. I hope I don’t mislead anyone for using the name XHTML :P. I just want an extended HTML helper.
echo $html->link( 'Link Test', array( 'controller' => 'long_controller_name', 'actions' => 'index', 'plugin' => 'long_plugin_name' ) );
I am a lazy typist and so I wanted to be able to use shortcut names for the array keys such as the following:
c = controller a = action p = plugin OR use numbers 0 = controller 1 = action 2 = plugin
I couldn’t find in the bakery any solution so I decided to create my own Html helper. Here is how you can install it:
First, add this file to your helpers folder located in
/cakedir/app/views/helpers/
Download XHTML Helper
Then, in your controller file, include the Xhtml to your helpers list. Example
class MyController extends AppController { ... var $helpers = array( 'Xhtml' ); ... }
That’s it. You can use it by doing the following:
echo $xhtml->link( 'Link Test', array( 'c' => 'long_controller_name', 'a' => 'index', 'p' => 'long_plugin_name' ) );
OR
echo $xhtml->link( 'Link Test', array( 'long_controller_name', 'index', 'long_plugin_name' ) );
Take note of using xhtml instead of html. I hope I don’t mislead anyone for using the name XHTML :P. I just want an extended HTML helper.
Tags: html helper, route


![[Bloglines]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/bloglines.png)
![[del.icio.us]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/delicious.png)
![[Facebook]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/google.png)
![[MySpace]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/myspace.png)
![[Newsvine]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/newsvine.png)
![[Squidoo]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/squidoo.png)
![[StumbleUpon]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/technorati.png)
![[Twitter]](http://cakephp.prometsupport.com/wp-content/plugins/bookmarkify/twitter.png)