Getting the page title from the new PageTitle - typo3

I'm looking for a way to get the page title set via the new PageTitleProvider API to display it inside a FluidTemplate.
In one of our TYPO3 installations, the page title is used as title, displayed on the page itself. The main PAGE object is set up to render a FLUIDTEMPLATE object. I've implemented the examples on the new PageTitleAPI in the documentation, https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/PageTitleApi/Index.html into my extensions and that works just fine for the tag.
However, within the page itself, the title set in the page is still displayed, not the title I've set in my extension.
I've figured out, that I can instantiate the PageTitleProviderManager, but getTitle still resolves to the page name, not the title I've set, most likely because this object is resolved before the PageTitleProviders are set up by the extensions.
$pageTitleProviderManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\PageTitle\PageTitleProviderManager::class);
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump( $pageTitleProviderManager->getTitle() );
// -> outputs the page name, not the title custom page title
Is there a way to resolve the page title after all Providers are processed and display it in a fluid template?

I also assume it depends on order of execution. so you need to build an order where your plugin is executed before the page title is rendered in the page template.
nowadays most integrators use the f:cObject viewhelper to render the content with lib.content. that means the content (and your plugin is rendered very late), as the page title is probably rendered before any content in the page template (independend whether you use template variables from the page template or a viewhelper which executes PHP or typoscript in the moment of the rendering.
Here you get a hint how to change the order:
try to render the content (including plugins) into a fluid-variable with the page templating ( e.g.:
page.10 = FLUIDTEMPLATE
page.10.variables.content < styles.content.get
) and try to get the page title when the page fluid is rendered: use a viewhelper to get the page title when the initial FLUID variables are already computed.
of course you also can define a FLUID-variable for the content in the page FLUID template before accessing the page title by viewhelper:
<f:variable name="content"><f:cObject typoscriptObejctPath="lib.content" /></f:variable>

Related

Show other field than title for some page types in TYPO3 backend page tree

We have an extension in TYPO3 8.7, which we're updating to TYPO3 10.4. One thing the extension does is alter the page tree in the backend so for some page types a different field than title is shown. For TYPO3 8 we're using a hook for that: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/tree/pagetree/class.t3lib_tree_pagetree_dataprovider.php']['postProcessCollections'] where we could loop through the page tree nodes, check the doktype and replace the text.
The page tree has been completely rewritten in TYPO3 9, so this hook doesn't exist anymore. I've looked in the new TYPO3\CMS\Backend\Controller\Page\TreeController class, but don't see any Signal Slot or PSR-14 event in that class we can use.
Is there a way to manipulate the page tree in this way in TYPO3 10?
If you use the Navigation Title field (nav_title) provided by TYPO3 out of the box, you can use the Page TSConfig option showNavTitle to prefer that in the page tree if set for a page:
pageTree {
showNavTitle = 1
}
If nav_title is empty, the regular title is shown instead.

How to set the body background for typo3 without or with extension?

I am using typo3 v9.5.0. I need to design a website with a background image wrapped all over the content element and menu. There is no specified layout in bootstrap package. I've tried extensions like background by uploading the image.
But there is something wrong. By default its pointing the wrong resource which it left(typo3/01_DBM).
I have no clue why it's behaving like that. If there is any other extension or technique, kindly suggest me. But I want it to be done dynamically because it needs regular updation.
TYPO3 9.5.0 is outdated. although you use it localy update to current version.
you have multiple options to integrate a background image to the whole page.
Here my recommandation which does not require any specific extension:
As you use the bootstrap-package you can enhance the Fluid-templates of it in your own site-extension (which you should use).
Where do you get the image from?
Every pages record (defining a page in TYPO3) has fields for related media files (you can find/set it on the Resources tab.
Here an editor can easily insert an image which should be used as a background image to the content.
In your typoscript definition of variables for the page you can define an own variabel for the first image
10 = FLUIDTEMPLATE
10 {
[...]
dataProcessing {
111 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
111 {
references {
fieldName = media
table = pages
}
as = BackgroundImages
}
}
[...]
}
and use it in the fluid template for the page like:
[...]
<div style="background-image:url(fileadmin/{BackgroundImages.0.originalFile.identifier});">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{pageUid: '{data.uid}', colPos: '0'}" />
</div>
[...]
further enhancements could use a sliding mechanism, so a page without own background-image could use the image of parent page.

TYPO3: How to properly setup RTE in custom content element

I created a custom content element with a "bodytext" field like this:
bodytext;Text;;richtext:rte_transform[flag=rte_enabled|mode=ts_css],
rte_enabled;LLL:EXT:cms/locallang_ttc.xlf:rte_enabled_formlabel
The text editor doesn't work properly. The links for example are formated like this:
<link 88 - internal-link>test</link>
which doesn't work in the frontend.
RTE is also throwing a lot of info and errors in the backend, here is a screenshot of firebug:
If I use a core content element like "text & media" RTE does work perfectly .. So I guess there is some configuration missing in my extension ?
How did you set up your custom content element? In which file did you set up your bodytext field shown above?
The link formatting like <link></link> is the normal and correct behavior of the RTE. By this way, links can be rendered dynamically having the pageid saved and they will still work even if the domain or pagetitle of the target page changes - this would not work if links would be saved "hard" like <a href="xy">.
However, those link tags have to be rendered using the lib.parseFunc_RTE when outputting the content. For example if you use Fluid for output, just use <f:format.html>{yourBodytextVariable}</f:format.html> and you will get correct links (f:format.html uses lib.parseFunc_RTE by default).
Check out your Typoscript Object Browser to find out more about the lib.parseFunc_RTE object and check out this doc: https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Parsefunc/Index.html

Do you need to add some Typoscript when using flux:grid together with v:content.render?

I am attempting to use Fluid templates to render pages. I have created an extension file provider and some page templates which appear to be rendering.
Unfortunately, the content I add to pages is not rendering.
I am attempting to follow the example in the Flux documentation (Two-column page template and Page Rendering sections).
I have also been reading the Creating Page Template page in the Fluid documentation.
When I do this, it correctly makes the grid layouts available in the TYPO3 backend.
However, when I select one of those layouts for a page, and then add some content, the content is not rendered in the page.
Am I missing a step? For example, is there some Typoscript I need to write here? The documentation appear to be incomplete/unfinished.
I have tried adding the following Typoscript in Configuration/Typoscript/setup.txt:
page {
10 {
variables {
left < styles.content.get
left.select.where = colPos = 0
right < styles.content.get
right.select.where = colPos = 1
}
}
}
But it had no effect.
Did you include the static templates of either css styled content or fluid styled content?

How can I avoid displaying the web-view-link IN the web view of TYPO3-ext newsletter?

I'm using TYPO3 newsletter extension and I'm looking for a solution not to display the link to the web view again when the web view already is shown.
newsletter is an extension that makes it possible to send pages as an email. If the users clicks on the link in the email, a browser window opens with a web view of the newsletter. I want to avoid the redundant display of this link.
In my newsletter fluid template i've got the following line:
###:IF: newsletter_view_url ###<p>If this e-mail cannot be display correctly, please click here.###:ENDIF:###</p>
The placeholders are delivered exclusively by the extension, so they are - as you see - no typoscript vars. The problem is: newsletter_view_url is always filled with a value and also the other possible vars always take the same value in email view as well as in web view.
What i tried so far:
Assign some var to the fluid template to distinct the web view from the email view:
# Create a Fluid Template
page.10 = FLUIDTEMPLATE
page.10 {
# Set the Template Paths
partialRootPath = {$privateTemplatePath}Partials/
layoutRootPath = {$privateTemplatePath}Layouts/
variables {
controllerAction = TEXT
controllerAction.data = GP:tx_newsletter_p|action
}
}
and in the fluid template file:
<f:if condition="{controllerAction}"><p>If this e-mail cannot be display correctly, please click here.</p></f:if>
Problem: controller action does not take any value though it is set in the get-string while opening the url from the newsletter:
test.html?type=1342671779&tx_newsletter_p%5Bc%5D=a0648d94a22dd5928762b1bd5f82e9de&tx_newsletter_p%5Baction%5D=show& ...
It also does not work if i use controller action for a typoscript condition
controllerAction = TEXT
controllerAction.value = 1
[globalVar = GP:tx_newsletter_p|action = show]
controllerAction.value = 0
[global]
I would be very grateful for further inspirations! Thank you so much!
According to this feature request, it is not implemented yet:
https://github.com/Ecodev/newsletter/issues/19
I suggest contacting author and submitting pull request with this change. As of how to implement it, might be changing the PHP code to add custom parameter to the URL when viewing in browser which would hide any part of newsletter template.