我试图加入标题元数据标签,这是我的代码:添加在头meta标签锂PHP
应用程序/扩展/帮手/ FacebookHtml.php
<?php
namespace app\extensions\helper;
class FacebookHtml extends \lithium\template\Helper {
protected $_strings = array(
'title' => '<meta property="og:title" content="{:contenido}" />',
'site_name' => '<meta property="og:site_name" content="{:contenido}" />',
'url' => '<meta property="og:url" content="{:contenido}" />',
'description' => '<meta property="og:description" content="{:contenido}" />',
'image' => '<meta property="og:image" content="{:contenido}" />',
'image' => '<meta property="og:image" content="{:contenido}" />',
'locate' => '<meta property="og:locate" content="{:contenido}" />',
);
public function meta($contenido, $options) {
return $this->_render(__METHOD__, $options['type'], compact('contenido'));
}
}
在app /视图/布局/ default.html.php,内部
<?=$this->FacebookHtml(); ?>
在其它视图的文件:
<?=$this->FacebookHtml->meta('title', 'Test.. 1...2...3...'); ?>
我在Google和核心代码中查找数小时以了解如何添加元数据。
真棒!!!其实真的很简单!谢谢你的时间和知识队友,真的很感激!!你是男人,欢呼!! –
很好的答案...钉了它!:) – Oerd