leogout / SeoBundle

A Symfony bundle to generate SEO meta tags.
38 stars 16 forks source link

More meta tags like pagination next and previous #21

Closed RomanApunts closed 4 years ago

RomanApunts commented 4 years ago

Hello i use this package for one of my project for manage SEO tags, but i miss other not essencial tags like rel = next / previous for pagination seo, I locked in one fork of this package by Leadtech this functionality are implemented, will you add these modifications on master SeoBundle?¿

Thanks in advance, i dont know if there is the correct way of tell you that questions...

leogout commented 4 years ago

Hello, this project is not under active devlopment anymore, but I am merging pull requests when I think they contribute to it. Feel free to make a PR or to ask for Leadtech to make one.
With that said I should let you know that you do not need to fork and edit the bundle for that use case. If you read the documentation there are plenty of ways to define your own tags, both statically and programmatically.

RomanApunts commented 4 years ago

Oh okey, i got it.

Then i will lets create a custom tag for that purpose...

Now i have a little problem creating my customtaggenerator, maybe you can help me here:

Custom class for news meta elements; `namespace App\Utils;

use Leogout\Bundle\SeoBundle\Seo\AbstractSeoGenerator;

class CustomTagsGenerator extends AbstractSeoGenerator {

public function setNextUrl($url)
{
    $this->tagBuilder->addLink('nextUrl')
        ->setHref((string)$url)
        ->setRel('next');

    return $this;
}

/**
 * @return \Leogout\Bundle\SeoBundle\Model\LinkTag|null
 */
public function getNextUrl()
{
    return $this->tagBuilder->getLink('nextUrl');
}

}`

My services.yaml ( note these are Symfony 5.0.8): services: App\Utils\CustomTagsGenerator: arguments: [ '@leogout_seo.builder' ] # This is required tags: { name: leogout_seo.generator, alias: custom }

Error when using that code are this:

Tag "leogout_seo.generator" requires an "alias" field in "App\Utils\CustomTagsGenerator" definition.

But im telling that alias tag like in your documentation. that alias not well specified or something?¿

RomanApunts commented 4 years ago

Finaly o solved my problem with structure of service lines like this work:

App\Utils\CustomTagsGenerator:
    arguments: [ '@leogout_seo.builder' ] # This is required
    tags: 
        - { name: leogout_seo.generator, alias: custom }
leogout commented 4 years ago

Glad I could help, have a nice day