CakePHP adding image to echo $this->Html->link -


hi have tried various things not sure if trying on complicate things. quite want add small image country flag word 'spanish' , 'english' , have 'alt' tag words instead. following works fine text , cool have image either replace or sit side side word. available?

    echo $this->html->link('spanish', array('controller'=>'settings', 'action'=>'lang', 'spa'),         array('rel'=>'nofollow')); }  else {     echo $this->html->link('english', array('controller'=>'settings', 'action'=>'lang', 'eng'),         array('rel'=>'nofollow')); } 

you can either output linked image using image method url attribute:-

<?php  echo $this->html->image(     'spain.jpg',      array(         'alt' => 'spanish',         'url' => array('controller' => 'settings', 'action' => 'lang', 'spa')     ) ); 

or can include image text link combining normal cakephp link method , image method:-

<?php  echo $this->html->link(     h('spanish') . $this->html->image('spain.jpg', array('alt' => 'spanish')),     array('controller' => 'settings', 'action' => 'lang', 'spa'),     array('escape' => false, 'rel' => 'nofollow') ); 

with link method need remember prevent cake escaping img tag using 'escape' => false. if disable escaping work remembering escape user provided text using h() method prevent html injection (i've shown in example wrapping word 'spanish' necessary if coming variable).


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -