我如何分配一个id和类与$ this-> Html-> link(..);? [英] How can I assign an id and class with $this->Html->link(..);?

查看:86
本文介绍了我如何分配一个id和类与$ this-> Html-> link(..);?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

echo $this->Html->link(
    'more',
    array(
        'controller'=>'posts',
        'action'=>'view',
        $post['Post']['id']
    ) 
);

如何为此锚点/链接分配id和类?

How can I assign an id and class for this anchor/link? I want to override its css rule.

推荐答案

HTML属性可以在数组中指定为第三个参数。

HTML attributes can be specified in an array as the third parameter.

echo $this->Html->link(
    'more',
    array(
        'controller'=>'posts',
        'action'=>'view',
        $post['Post']['id']
    ),
    array(
        'id' => 'myId',
        'class' => 'myClass'
    )
);

Cookbook 2.x 适用于2.x版本或 Cookbook 1.3 for CakePHP 1.3。

More info in the Cookbook 2.x for the 2.x version or Cookbook 1.3 for CakePHP 1.3.

这篇关于我如何分配一个id和类与$ this-> Html-> link(..);?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆