如何在cakephp中的.ctp文件中设置元标记逻辑?

时间:2014-11-05 11:46:48

标签: php html css cakephp

我尝试将此代码转换为cakephp代码......

<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

我试试这个

$this->Html->meta(array('charset'=>'utf-8'));
$this->Html->meta(array('content'=>'IE=edge,chrome=1'), array("http-equiv" => X-UA-Compatible));
$this->Html->meta("viewport", array("content" => width=device-width,initial-sacale=1.0));
$this->Html->meta("description");
$this->Html->meta("author");

但它不起作用...............

我是cakephp的新手....所以请帮我解决这个问题...

2 个答案:

答案 0 :(得分:6)

试试这个 -

echo $this->Html->meta(
    'keywords',//name
    'enter any meta keyword here'//content
);

所以为此 -

<meta name="viewport" content="width=device-width, initial-scale=1.0">

echo $this->Html->meta(
    'viewport',//name
    'width=device-width, initial-scale=1.0'//content
);

docs了解详情和其他选项。

代表charset - echo $this->Html->charset('ISO-8859-1');

尝试 -

echo $this->Html->meta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0',  'http-equiv' => "X-UA-Compatible"));

答案 1 :(得分:-1)

<?= $this->Html->meta(
    false,
    'ie=edge',
    ['http-equiv' => 'x-ua-compatible']
    );
    ?>

....结果

<meta http-equiv="x-ua-compatible" content="ie=edge"/>