lemonmind / pimcore-simple-seo-bundle
Pimcore 的简单 SEO 扩展包
1.0.0
2023-02-13 13:14 UTC
Requires
- leogout/seo-bundle: ^1.3
- pimcore/pimcore: ^10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- phpstan/phpstan: ^1.8
- phpstan/phpstan-symfony: ^1.2
This package is not auto-updated.
Last update: 2024-09-24 19:32:13 UTC
README
SEO 扩展包,允许您快速完成元数据
安装
composer require lemonmind/pimcore-simple-seo-bundle
在 config/bundles.php
文件中添加
return [ // another bundles Leogout\Bundle\SeoBundle\LeogoutSeoBundle::class => ['all' => true], Lemonmind\PimcoreSimpleSeoBundle\LemonMindPimcoreSimpleSeoBundle::class => ['all' => true], ];
在 config/config.yaml
文件中添加
基本配置
leogout_seo: general: ~ basic: ~ og: ~ twitter: ~ lemon_mind_pimcore_simple_seo: ~
元图像缩略图
lemon_mind_pimcore_simple_seo: thumbnail_name: 'simple_thumb_name'
标题模式
lemon_mind_pimcore_simple_seo: title_pattern: before: 'Content before seo title' after: 'content after seo title'
用法
在基本模板中添加
<head> {{ leogout_seo() }} </head>
文档
只需在 SEO 部分完成字段,并创建(可选)名为 meta_tag_image 的自定义属性,属性值为文档的资产
在 controller
中添加
public function defaultAction(DocumentSeoMetaGenerator $seoMetaGenerator): Response { $seoMetaGenerator->generate($this->document); return $this->render('default/default.html.twig'); }
对象
应在对象定义中添加接口 \Lemonmind\PimcoreSimpleSeoBundle\Model\ObjectSeoInterface
然后,根据接口(\Lemonmind\PimcoreSimpleSeoBundle\Model\ObjectSeoInterface
),创建必要的字段
- seoTitle (text->input)
- seoDescription (text->textarea)
- seoKeywords (text->input)
- seoImage (media->image)
在控制器中
public function seoObjectAction(ObjectSeoMetaGenerator $seoMetaGenerator): Response { /** * @var ObjectSeoInterface $test */ $test = Test::getById(1); $url = 'absolute url to this object'; $seoMetaGenerator->generate($test, $url); return $this->render('default/default.html.twig'); }