如何通过CakePHP中的Html Helper截断链接?
这本书只截断文本字符串,但是如何截断这样的链接?
$this->Html->link('This is a very long link that needs to be truncated', '/pages/home', array('class' => 'button', 'target' => '_blank'));
由于
答案 0 :(得分:6)
将使用情况与TextHelper :: truncate方法结合使用。例如:
$this->Html->link(
$this->Text->truncate('This is a very long link that needs to be truncated'),
'/pages/home',
array('class' => 'button', 'target' => '_blank')
);