Changes made to page via TSFE not visible

Hey there,

I’m developing some extensions for our new site to get familiar with Extbase, controllers, etc.
Now I’m facing a behavior I cannot really explain and thought somebody here might know what’s up.

For context:
I’m building a backend module for job management and I tried to dynamically set meta data for the job detail pages in my controller, like so:

$tsfe = $request->getAttribute('frontend.controller');
$tsfe->page["og_title"] = "Whatever";

This works great.

But then I tried to set other page properties to render them in the frontend, which didn’t work out. I have previously added fields like hero_header to the pages table, so that I can manage the hero section of “normal pages” via the page properties in the backend. This works - I simply pass the page arguments to my hero partial:

<f:layout name="Default" />
<f:section name="Main">
    <div class="app" id="app">
        <f:render partial="Navigation" arguments="{_all}"/>
        <main class="main-content" id="main-content">
            <f:render partial="Hero" arguments="{_all}"/>
            <f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '0'}"/>
        </main>
        <f:render partial="Footer" arguments="{_all}"/>
    </div>
</f:section>

And now my problem:
The issue is that the job detail pages are not “normal pages”, but a plugin, and I cannot edit the page properties in the backend. So I tried the above method and used the frontend controller to set them:

$tsfe->page["hero_header"] = "Job title or whatever";
debug($tsfe->page); // it's there, yay!

Then I checked if the data was also present in the frontend. Nope, it’s not there. Although the meta data got applied to the view, I don’t see any of the dynamically added data in the debug output in my default template. It is there in the controller but not in the frontend.
Why is that?

Hey,

I’d suggest to use the core APIs to manipulate the meta tags, title, etc.
See: Search engine optimization (SEO) — TYPO3 Explained main documentation

1 Like

TSFE->page is the actual database record of the current page. TYPO3 will use some data down the road, that’s why modifying og_title worked. But hero_header is unknown to TYPO3 and won’t magically appear somewhere.

I’m not sure what you mean by:

also present in the frontend

As hero_header is nothing a browser knows about. So what is your use case, what exactly are you trying to achieve? I could imagine you are trying to pass additional data to your template? That can be done with $this->view->assign() inside your controller: View — TYPO3 Explained 12.4 documentation

1 Like