11

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.

4 Answers 4

32

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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;'));

Comments

1

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']);
?> 

Comments

-1

I think this works:

<?php echo $this->Html->link('Add Task', array('action'=>'add'), array('class' => 'tac')); ?>

1 Comment

You should make sure that your answer is worked and you already try it.

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.