如何使用$ this-> Html-> link(..);?分配ID和类?

时间:2011-07-31 14:17:51

标签: cakephp cakephp-1.3

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

如何为此锚/链接分配ID和类?我想覆盖它的css规则。

1 个答案:

答案 0 :(得分:10)

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

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

2.x版本的Cookbook 2.x或CakePHP 1.3的Cookbook 1.3更多信息。