在CakePHP 3中自定义锚定标记
我目前正在CakePHP 3应用程序的default.ctp中的菜单中使用以下语法在CakePHP 3中自定义锚定标记,php,html,cakephp,cakephp-3.0,Php,Html,Cakephp,Cakephp 3.0,我目前正在CakePHP 3应用程序的default.ctp中的菜单中使用以下语法 <li class="first"><a href="<?php echo $url; ?>users/dashboard"><span class="glyphicon glyphicon-th-list"></span><br>Dashboard</a></li> 现在,如果我尝试用CakePHP 3语法编写
<li class="first"><a href="<?php echo $url; ?>users/dashboard"><span class="glyphicon glyphicon-th-list"></span><br>Dashboard</a></li>
现在,如果我尝试用CakePHP 3语法编写标记,问题就会出现,如下所示:
<li><?php echo $this->Html->link('Dashboard',['controller'=>'Users', 'action'=>'view','_full'=>true]);?></li>
正如你们所见,并没有地方把标签放在上面,因为那个字形从菜单中消失了
有没有办法解决我找不到的问题?尝试使用:
echo $this->Html->link(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-th-list')) . "Dashboard",
array('controller' => 'users', 'action' => 'view'),
array('escape'=>false)
);
尝试使用:
echo $this->Html->link(
$this->Html->tag('span', '', array('class' => 'glyphicon glyphicon-th-list')) . "Dashboard",
array('controller' => 'users', 'action' => 'view'),
array('escape'=>false)
);
使用
'escape'=>false
解决您的问题
<li>
<?php
echo $this->Html->link(
'<span class="glyphicon glyphicon-th-list"></span><br>Dashboard',
array('controller'=>'Users', 'action'=>'view','_full'=>true),
array('escape' => false) // important
);
?>
</li>
使用'escape'=>false
解决您的问题
<li>
<?php
echo $this->Html->link(
'<span class="glyphicon glyphicon-th-list"></span><br>Dashboard',
array('controller'=>'Users', 'action'=>'view','_full'=>true),
array('escape' => false) // important
);
?>
</li>
如果您与HTML链接助手相处不好,可以使用更短的方式,更少的php代码
并根据需要创建菜单/html链接
<li class="first">
<a href="<?= $this->Url->build(['controller'=>'Users', 'action'=>'view','_full'=>true]); ?>">
<span class="glyphicon glyphicon-th-list"></span>
Dashboard
</a>
</li>
如果您与HTML链接助手相处不好,可以使用更短的方式,更少的php代码
并根据需要创建菜单/html链接
<li class="first">
<a href="<?= $this->Url->build(['controller'=>'Users', 'action'=>'view','_full'=>true]); ?>">
<span class="glyphicon glyphicon-th-list"></span>
Dashboard
</a>
</li>
使用escapeTitle
选项
$this->Html->link(
'<span class="glyphicon glyphicon-th-list"></span><br>Dashboard',
['controller'=>'Users', 'action'=>'view','_full'=>true],
['escapeTitle' => false]
);
$this->Html->link(
“
仪表板”,
['controller'=>'Users'、'action'=>'view'、'u full'=>true],
['EscapeTile'=>错误]
);
使用escapeTitle
选项
$this->Html->link(
'<span class="glyphicon glyphicon-th-list"></span><br>Dashboard',
['controller'=>'Users', 'action'=>'view','_full'=>true],
['escapeTitle' => false]
);
$this->Html->link(
“
仪表板”,
['controller'=>'Users'、'action'=>'view'、'u full'=>true],
['EscapeTile'=>错误]
);
以上两种答案我都试过了。输出应该是这样的 。但是它是这样的,我已经尝试了以上两种答案。输出应该是这样的。但它是这样的class=“glyphicon glyphicon th list”/span