Codeigniter : link_to helper

if (!function_exists('link_to'))
{
        function link_to($object, $text, $method="view")
        {
            get_instance()->load->helper('inflector');
            return anchor(plural(strtolower(get_class($object)))."/".$method."/".$object->id, $text);
        }
}

// An helper method I use in my CodeIgniter apps. Now you can type:

<?= link_to($user, $user->name); ?>

// instead of:

<?= anchor("users/view/".$user->id, $user->name); ?>
Processing your request, Please wait....

No Responses to “Codeigniter : link_to helper”

Comments (Your Comments)

Leave a Reply

You must be logged in to post a comment.