Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call CSS class on a CakePHP Html->link?

Tags:

cakephp

I am a complete noob to programming and CakePHP all together, so please be patient. How am I supposed to call the CSS on this Html->link:

<?php echo $this->Html->link(__('Blogs', true), array('controller' => 'posts', 'action' => 'index') ); ?>

Please help.

like image 838
Newbie Coder Avatar asked May 27 '11 08:05

Newbie Coder


3 Answers

Not sure what you mean by "call the css", I think you want to add a class to this link? IF that's the case you can just add another array as an argument and it will turn key =? value into HTML attributes. EG:

echo $this->Html->link(__('Blogs', true), array('controller' => 'posts', 'action' => 'index'), array('class' => 'my-class'));

This is all explained in the CakePHP docs.

like image 197
Dunhamzzz Avatar answered Nov 07 '22 06:11

Dunhamzzz


Another Solution will be the inline style :

echo $this->Html->link(__('Blogs', true), array('controller' => 'posts', 'action' => 'index'), array('style' => 'color:red;font-size:20px;'));
like image 3
MasterMind Avatar answered Nov 07 '22 05:11

MasterMind


Please try this CakePHP 3 in

<?php 
echo  $this->Html->link(__('Blogs'), ['controller' => 'posts', 'action' => 'index'], ['class' => 'mb-xs mt-xs mr-xs btn btn-warning']);
?> 
like image 1
Manvendra singh bhati Avatar answered Nov 07 '22 05:11

Manvendra singh bhati