2

How can I use $html->link from within an element?

Thanks,
Tee

2
  • 1
    What version of cakephp? In 1.3 it just works. There is somewhere a parameter to control the passing of helpers to elements in 1.2 as far as I remember. Commented Apr 12, 2010 at 10:41
  • In the versions of 1.2 I've used, Helpers are automatically passed into view elements. Commented Apr 12, 2010 at 15:37

2 Answers 2

3

In both 1.2 and 1.3,this should work:

echo $html->link('linkname',array('controller'=>'somecontroller','action'=>'someaction/somearguments'));

Update

The html helper has changed a little in version 2.x.An example from the cook book

echo $this->Html->link('Enter', '/pages/home', array('class' => 'button', 'target' => '_blank'));
Sign up to request clarification or add additional context in comments.

Comments

0

The new version of Cakephp has easier ways to work with html->links, definitely you can convert links into buttons.

If you want using bootstrap or some css however for normal links you can use:

<?= $this->Html->link ('Sometexthere', ['controller' =>'myController', 'action' =>'myAction']); ?>

1 Comment

It's good practice on StackOverflow to add an explanation as to why your solution should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.