gercoli/metatags
Composer 安装命令:
composer require gercoli/metatags
包简介
Wrapper for the HTMLTags class geared toward meta tags.
README 文档
README
An extension for GErcoli/HTMLTags to make managing common meta tags easier.
Installation
Include this into your composer.json file:
{ "require": { "gercoli/metatags": "dev-master" } }
Using the class
The MetaTags class uses fully qualified name spaces, so for easier use, add use GErcoli\MetaTags\MetaTags into your php file.
Secondly, the class has been designed to be used statically and the various setter methods can be chained together.
Example of a simple tag
MetaTags::setTitle("This is the page title"); echo MetaTags::getTitle(); // output: // "This is the page title" MetaTags::renderTitle(); // output: // <title>This is the page title</title> MetaTags::setCharset("UTF-8") ->setDescription("This is the page \"description\".") ->renderAll(); // output: // <meta charset="UTF-8"> // <title>This is the page title</title> // <meta name="description" content="This is the page "description".">
Custom tags
It is inevitable that there will tags that you need to output/render that do not have easy-to-access class methods, for this purpose I've added the addCustomTag(HTMLTag) method, where you can use the dependant class \GErcoli\HTMLTags\HTMLTag to create an HTMLTag and insert it manually.
// Create the custom tag via the HTMLTag class: $tag = (new HTMLTag("meta")) ->setAttribute("http-equiv","Content-Language") ->setAttribute("content","en"); // Add the created tag to the MetaTags object, // and render only the very last tag that was added: MetaTags::addCustomTag($tag)->renderLast(); // output: // <meta http-equiv="Content-Language" content="en">
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-21