Reputation: 95
I have a button called 'buy now' where the href is a value from a gallery_url field.
When I click the button i get a URL like this:
http://localhost:8080/mysite/artworks/view/http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FMain_Page
Whereas it should be like this:
http://en.wikipedia.org/wiki/Main_Page
I'm new to Cakephp2, here is my code below
<li>
<?php echo $this->Html->link('Buy now', array($artwork['Artwork']['gallery_url']), array ('class' => 'btn btn-buy'));?>
</li>
Upvotes: 1
Views: 776
Reputation: 518
Here is the documentation of Link function in HtmlHelper:
http://api.cakephp.org/3.2/class-Cake.View.Helper.HtmlHelper.html#_link
Supposing that you are using "http://" on your link, what you need to do is delete this "array($link)" of your code. You should pass the second argument as string, not as array.
Try this:
<li>
<?php echo $this->Html->link('Buy now', $artwork['Artwork']['gallery_url'], array ('class' => 'btn btn-buy'));?>
</li>
Upvotes: 2