lemonmind/pimcore-simple-seo-bundle

Simple seo bundle for Pimcore

1.0.0 2023-02-13 13:14 UTC

This package is not auto-updated.

Last update: 2024-12-17 20:35:53 UTC


README

Seo package that allows you to complete metadata very quickly

Installation

composer require lemonmind/pimcore-simple-seo-bundle

in the config/bundles.php file add

return [
    // another bundles
    Leogout\Bundle\SeoBundle\LeogoutSeoBundle::class => ['all' => true],
    Lemonmind\PimcoreSimpleSeoBundle\LemonMindPimcoreSimpleSeoBundle::class => ['all' => true],
];

in the config/config.yaml file add

Basic configuration

leogout_seo:
    general: ~
    basic: ~
    og: ~
    twitter: ~

lemon_mind_pimcore_simple_seo: ~

Meta image thumbnail

lemon_mind_pimcore_simple_seo:
    thumbnail_name: 'simple_thumb_name'

Title pattern

lemon_mind_pimcore_simple_seo:
    title_pattern:
        before: 'Content before seo title'
        after: 'content after seo title'

Usage

in base template add

<head>
    {{ leogout_seo() }}
</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

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 \Lemonmind\PimcoreSimpleSeoBundle\Model\ObjectSeoInterface

Then, according to the interface(\Lemonmind\PimcoreSimpleSeoBundle\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');
}