monsat/ogp

CakePHP OGP 插件

维护者

详细信息

github.com/monsat/Ogp

源代码

问题

安装量: 38,770

依赖者: 0

建议者: 0

安全: 0

星标: 9

关注者: 4

分支: 2

开放问题: 0

类型:cakephp-plugin

dev-master 2014-05-20 05:34 UTC

This package is not auto-updated.

Last update: 2024-09-24 06:56:49 UTC


README

CakePHP OGP 插件

使用说明

# view
$this->Ogp->title('page title');     // add title tag
$this->Ogp->image($post['Post']['author_image_url']);
// the other property
$this->Ogp->set(
  'description',                     // name="og:description"
  "stripped \n and <b>tags</b>",     // content
  // options
  array(
    'meta' => true,                  // add normal meta tag
  ),
);

# layout
$this->fetch('meta');

安装

下载此代码

下载此代码,并将其放入您的插件目录。

cd your_app
ls Plugin

Ogp

或克隆/子模块添加

cd your_app
git clone git://github.com/monsat/Ogp.git Plugin/Ogp

加载插件

# APP/Config/bootstrap.php
CakePlugin::load('Ogp');
# APP/Controller/AppController.php
$helpers = array( 'Html', 'Form', 'Ogp.Ogp');

默认设置

如果您在视图中没有设置值,则使用默认值。

# APP/Config/bootstrap.php
Configure::write('Site', array(
  'site_name' => 'My Site',
  'description' => 'My Site is awesome',
  'image' => '/img/image.png',
  'type' => 'website',
  'separator' => ' - ',
));

设置

默认设置

Configure::write('Ogp.settings', array(
  'base' => 'Site.',
  'autoKeys' => array('type'), // set by beforeLayout
));