Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Head Meta Generator

The Head Meta Generator creates some additional meta information for the news detail page (like head title, meta description and some open graph elements).

Create a custom Generator

Just override the build in generator:

news:
    relations:
        NewsBundle\Generator\HeadMetaGenerator: AppBundle\Generator\AppHeadMetaGenerator

And set up your new class:

<?php

namespace AppBundle\Generator;

use NewsBundle\Model\EntryInterface;
use NewsBundle\Generator\HeadMetaGenerator;

class AppHeadMetaGenerator extends HeadMetaGenerator
{
    public function generateMeta(EntryInterface $entry): array
    {
        //always use the link generator to build a valid link
        $href = $this->linkGenerator->generateDetailLink($entry);
        $params = ['your_meta_tag_name' => $href];
        return $params;
    }
}