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

后端 未结 4 610
囚心锁ツ
囚心锁ツ 2020-12-16 20:47

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:



        
相关标签:
4条回答
  • 2020-12-16 20:55

    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']);
    ?> 
    
    0 讨论(0)
  • 2020-12-16 20:57

    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.

    0 讨论(0)
  • 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;'));
    
    0 讨论(0)
  • 2020-12-16 21:06

    I think this works:

    <?php echo $this->Html->link('Add Task', array('action'=>'add'), array('class' => 'tac')); ?>
    
    0 讨论(0)
提交回复
热议问题