Reputation:
I am making a Image link to user profile, but it is not working as it should be this is my code.with this i want to add contoroller,function and id. How i can do it.
<?php
$pic = $User['User']['url'];
if(!$pic){
echo $this->Html->link($this->Html->image('pro.jpg'), array('alt'=>$User['User']['handle'],'title' => $User['User']['handle']),array('escape'=>false) ,array('class'=>'inner_image'));
}else{
echo $this->Html->link($this->Html->image($User['User']['url']),array('alt' => $User['User']['handle']),array('escape'=>false),array('class'=>'inner_image'));
}
?>
This code is making image a link but i can't define a link and it is not accepting the class .I want to pass this url
$this->Html->link('', array('controller'=>'User','action'=>'view','id'=>$User['User']['id']));
Upvotes: 0
Views: 1423
Reputation:
This is how I did it
echo $this->Html->link($this->Html->image($pic, array('class'=>'inner_image')), $url_array, array('alt' => $User['User']['handle'], 'escape'=>false));
Upvotes: 1
Reputation: 4522
What cake version are you using? You don't seem to be following the documentation for Html::link
.
HtmlHelper::link(string $title, mixed $url = null, array $options = array(), string $confirmMessage = false)
alt
, escape
and class
should be indexes in the options
array, but you're not defininf the url
parameter anywhere.
It should be something like this
if(!$pic){
echo $this->Html->link($this->Html->image('pro.jpg'), $url_array, array('alt'=>$User['User']['handle'],'title' => $User['User']['handle'],'escape'=>false,'class'=>'inner_image'));
} else {
echo $this->Html->link($this->Html->image($User['User']['url']), $url_array, array('alt' => $User['User']['handle'], 'escape'=>false, 'class'=>'inner_image'));
(don't know what url you want to point this at, so replace $url_array
to your convenience.
Upvotes: 0