Manipulate meta-description and page-title

Hi there,

I’m building a simple Blog with Neos and have created an own plugin for this. All in all it workes well so far.

But in the plugins “show”-Action, which is called multiple times with different content, I need a dynamical meta-description and page-title for every dataset.

It’s a common matter, but I’m not sure if it’s possible with Neos / Flow.

Can someone help me?

Hi @DrPowers

Are you using Neos CMS for this or are you building your own Flow application with your own domain model?

Hi,

thanks for the answer.

I’m in my own Flow plugin in Neos-context (own domain model). And from my Controller/View I would like to manipulate the metadata.
http://neos.readthedocs.io/en/stable/ExtendingNeos/CreatingAPlugin.html

Principle like this:
(ZendFramework2)
$this->layout()->metaDescription = ‘’;
$this->pageTitle = ‘’;
(Typo3 Extbase)
$this->response->addAdditionalHeaderData(’’);

In Typo3 I also would know how to grab the GPvars in TypoScript and get the Information I need. But in Neos I don’t.

Actually I found a way to manipulate the metadescription for the show-action through a ViewHelper, which is called in the layout and fetching the data from the URL GET parameter - but I didn’t really like this solution.
Beside this I still missing a solution for a dynamical page title.

I got no answer or hints for this, so I figured it out by myself.

With an EEL Helper it’s quite easy to manipulate the meta tags of a page. Be aware I’m working with Neos 2.3 LTS - the namespaces here are “TYPO3” and not “NEOS”.

Here we go:

a) Write your EEL Helper (the Helper itself didn’t change from Neos V2 to V3). My helper returns the PageTitle as string:

Neos Doku - Custom EEL Helper

b) Settings.yaml:

TYPO3:
  TypoScript:
    defaultContext:
      'VENDOR.GetArgument': 'VENDOR\Site\Eel\Helper\GetArgumentHelper'

c) Add following to your Page.ts2:

    page = Page {
        head {
            titleTag = TYPO3.TypoScript:Tag {
                @cache {
                    mode = 'uncached'
                    context {
                        1 = 'node'
                        2 = 'documentNode'
                    }
                }
                tagName = 'title'
                content = ${VENDOR.GetArgument.myFunction()}
            }
        }
    }

If you’re giving a shot to the Example-ViewHelper from the Neos documentation, so replace “GetArgument” with “Example” and “myFunction” with “wrapInCurlyBrackets”.

The ‘uncached’ Part in the “titleTag”-Property is important in case of dynamical changes of the page title.