in-square / opendxp-seo-bundle
Seo bundle for OpenDXP
Package info
github.com/in-square/opendxp-seo-bundle
Type:opendxp-bundle
pkg:composer/in-square/opendxp-seo-bundle
Requires
- in-square/seo-bundle: ^1.0
- open-dxp/opendxp: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- phpstan/phpstan: ^1.8
- phpstan/phpstan-symfony: ^1.2
README
Seo package that allows you to complete metadata very quickly
Installation
composer require in-square/opendxp-seo-bundle
in the config/bundles.php file add
return [ // another bundles InSquare\OpendxpSeoBundle\InSquareOpendxpSeoBundle::class => ['all' => true], ];
in the config/packages/in_square_opendxp_seo.yaml file add
Basic configuration
in_square_opendxp_seo: ~
Meta image thumbnail
Set thumbnail_name to an existing image thumbnail definition from OpenDXP.
in_square_opendxp_seo: thumbnail_name: 'meta_tag_image'
Title pattern
in_square_opendxp_seo: title_pattern: before: 'Content before seo title' after: 'content after seo title'
Usage
in base template add
<head> {{ render_seo_tags() }} </head>
Document
Just complete the fields in the SEO section and create (optional) a custom property named meta_tag_image with the asset for the document.
If you want to provide keywords, use document property seo_keywords (text). This bundle also provides seo_keywords as a predefined property for documents.

in controller add
public function defaultAction(DocumentSeoMetaGenerator $seoMetaGenerator): Response { $seoMetaGenerator->generate($this->document); return $this->render('default/default.html.twig'); }
Object
An interface should be added to the object definition \InSquare\OpendxpSeoBundle\Model\ObjectSeoInterface

Then, according to the interface(\InSquare\OpendxpSeoBundle\Model\ObjectSeoInterface), create the necessary fields
- seoTitle (text->input)
- seoDescription (text->textarea)
- seoKeywords (text->input)
- seoImage (media->image)
in controller
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'); }

