我試圖加入標題元數據標籤,這是我的代碼:添加在頭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