copiaincolla/metatags-bundle
Composer 安装命令:
composer require copiaincolla/metatags-bundle
包简介
HTML Meta Tags management.
README 文档
README
Symfony2 Bundle to manage html meta tags by path matching. This bundle manages relative paths, and not absolute urls.
How it works
You, as developer, specify the paths you want to be visible to admins in a reserved area of your website. Then an admin can manually set meta tags values for a concrete path, or define some regex rules to be applied to apths. You can also set some meta tags in yout twig templates.
MetaTagsBundle loads some urls and manages the association between an url and its meta tags values storing the data in the database.
To choose which urls must be managed by MetaTagsBundle, you must load the routes generating them. There are some different methods to achieve this:
- load all the routes of a bundle by including the bundle name in
config.yml - for each route, specify the option
ci_metatags_exposein the Route annotation
For routes requiring parameters that must be fetched from database, there's the possibility to load entities from database, and associate the route parameters to the entities values in order to create urls.
For more specific needs, it is also possible to create a custom service which simply returns an array of urls.
Once the urls are loaded in MetaTagsBundle, you will be able to associate the following meta tags to each url:
- title
- description
- keywords
- author
- language
- robots
- googlebot
- og:title
- og:description
- og:image
It is possible to specify default values for each meta tag, used when a url has no or partially meta tags specified by the user.
Note: This bundle is in beta state at the moment, in test phase and almost ready for the first release.
Changelog
10/04/2014 - Version 2.1
Compatibility with Symfony 2.4 has been added.
03/03/2014 - Version 2.0
The templates of the admin area have been refactored, reducing the number of files. Compatibility with Symfony 2.3 has been introduced. Functionality "allow_edit_url" has been suspended.
20/08/2013 - Version 1.1
The version 1.1 is shipped! The most important introduction is the possibility to define cascading regex rules for default meta tag values.
05/04/2013 - Version 1.0
In this date the version 1.0 is tagged, hurray! This means that this bundle is no more in beta release, but ready for production environments.
24/01/2013 - Version 0.1
THe work on this bundle begins, now in alpha state.
Install
Installation instructions can be found in Installation.
The current version (master branch) of this bundle is compatible with Symfony >= 2.2.*
Tag notes
We will try to provide tags as best as we can, to be used proficiently with composer or deps.
The development of this bundle is intended for Symfony versions >= 2.0.*; here is a brief explanation of the tagging system we use:
- tags with the "X.Y" format are compatible with
Symfony >= 2.2.* - tags with the "S2.0/X.Y" format are compatible with
Symfony 2.0.* - tags with the "S2.1/X.Y" format are compatible with
Symfony 2.1.*
If you are using symfony 2.0.*, follow this guide on the symfony-2.0.x branch.
If you are using symfony 2.1.*, follow this guide on the symfony-2.1.x branch.
More details about tagging and branching system used in CopiaincollaMetaTagsBundle can be found in Tagging and Branching system explanation.
Configure
To configure this bundle, read Configuration for all possible values.
The default meta tag values are configurable by web interface, at url /metatags/defaults.
Load urls
To generate urls starting by all routes contained in a bundle, just add the bundle name to config.yml, as explained here.
You can also add a single route by specifying an option in the Route annotation, like this:
@Route("/product/{id}/{slug}", name="product_show", options={"ci_metatags_expose"=true})
Through this option, you can also choose not to generate urls from a specific route:
@Route("/product/{id}/{slug}", name="product_show", options={"ci_metatags_expose"=false})
You can also generate urls for associating meta tags by fetching data from database; read the section Configuration#dynamic_routes.
Finally, you can also create your custom urls loader service, by following this guide.
Display help message to user
You can specify a @Route option to display a message in the edit page, just use the ci_metatags_help options:
@Route("/product/{id}/{slug}", name="product_show", options={"ci_metatags_help"="This urls represents a product. Use {{ entity.title }} to print the title of a product"})
Usage in the templates
Currently only twig is supported.
In the template containing an <head> tag, simply add:
<body>
<head>
{% render controller('CopiaincollaMetaTagsBundle:MetaTags:render') %}
[...]
</head>
[...]
</body>
To overwrite the default meta tags and the custom meta tags inserted by web interface, you can specify the inlineMetatags variable:
{% render controller('CopiaincollaMetaTagsBundle:MetaTags:render', { 'inlineMetatags': {'title': 'New foo title'} }) %}
For a better explanation of usage in templates and advanced use, read Template usage.
copiaincolla/metatags-bundle 适用场景与选型建议
copiaincolla/metatags-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.43k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2012 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「html」 「tag」 「meta」 「metatag」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 copiaincolla/metatags-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 copiaincolla/metatags-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 copiaincolla/metatags-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Harvest statistics and meta data from an URL or his source code (seo oriented).
Phalcon PHP Meta tags service
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Help to manage meta data on Laravel Eloquent model
A simple, repeatable field type
统计信息
- 总下载量: 2.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-12-06