I have 3 roles in my app.
To Avoid adding the prefix arrays to each url, I am using this helper function.
View code to create musician prefix url:
echo $this->Html->link('Dashboard', $this->RoleLink->linkRole(array('controller'=>'users','action'=>'dashboard'),array('musician')));
Helper function:
function linkRole($default=array(),$whitelist=array()) {
return array_merge($default, array('prefix'=>array('admin','label','musician'),'admin'=> in_array('admin', $whitelist),'label'=>in_array('label', $whitelist),'musician'=>in_array('musician', $whitelist)));
}
I hope it will help someone or even better if someone will give me a simpler way to do it.
-- To Avoid adding the prefix arrays to each url, I am using this helper function.
View code to create musician prefix url:
echo $this->Html->link('Dashboard', $this->RoleLink->linkRole(array('controller'=>'users','action'=>'dashboard'),array('musician')));
Helper function:
function linkRole($default=array(),$whitelist=array()) {
return array_merge($default, array('prefix'=>array('admin','label','musician'),'admin'=> in_array('admin', $whitelist),'label'=>in_array('label', $whitelist),'musician'=>in_array('musician', $whitelist)));
}
I hope it will help someone or even better if someone will give me a simpler way to do it.
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment