After a "long way" with Google, Searching and many tries:
I created a lib.variable for the current Page:
lib.currentPage = TEXT
lib.currentPage.data = page:uid
If I debug it in my FluidTemplate in the Frontend with:
Testing currentPage: <f:cObject typoscriptObjectPath="lib.currentPage" />
I got the correct value.
Now I want to use that Variable in a Condition in my pageSetup.ts
like follows:
[DB:pages:lib.currentPage:backend_layout = pagets__pagelayout_logoclaim_subpage]
page.includeJSFooter.belayoutlogoclaim = EXT:rm_base/Resources/Public/JS/be_logoclaim.js
[end]
I testet this with some other Conditions, but nothing works like expected.
Tested Conditions:
- [page|backend_layout = pagelayout_logoclaim_subpage]
- [globalVar = TSFE:page|backend_layout = pagelayout_logoclaim_subpage]
I also tested the Condition in the TypoScript Object Browser, and here it looks like good working:
TypoScript Object Browser - If I activate the Condition
SourceCode in the Frontend on a Site with the correct PageLayout
I need this, because I have two different Menus, and they need different JavaScripts, to avoid wrong behaviour in the Frontend.
Update: I inserted the pageLayouts like this:
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
partialRootPath = EXT:rm_base/Resources/Private/Templates/Fluid/Partials/
layoutRootPath = EXT:rm_base/Resources/Private/Templates/Fluid/Layouts/
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = pagelayout
// Default-Template is LogoFull_Subpage (No Navigation Dependence)
default = TEXT
default.value = EXT:rm_base/Resources/Private/Templates/Fluid/LogoFull_Subpage.html
// LogoClaim - Subpage
pagets__pagelayout_logoclaim_subpage = TEXT
pagets__pagelayout_logoclaim_subpage.value = EXT:rm_base/Resources/Private/Templates/Fluid/LogoClaim_Subpage.html
}
}
You see: The Backendlayouts are in Files of my Extension, not in the Database-Table: backend_layouts.
Update 2:
I would prefer a TypoScript-Way, if someone knows how - with external BE-Layouts. Thank you.
The problem with the
backend_layout
field is that there also is a fieldbackend_layout_next_level
which affects subpages. so you can't build a simple condition.Either you use
stdWrap.if
where you can calculate the current value forbackend_layout
overlaying an inherited value frombackend_layout_next_level
.Or you define a userfunc where you evaluate it yourself in PHP.
Be aware that layouts defined in records have another prefix than layouts defined in pagesTS.
edit: Example
}
Now you can use
temp.layout
for further decisions:As I've seen the prefix
pagets__
,I guess that the problem here is that the backend_layouts are not stored in the database, so I think that a condition about that would not work.If you are using a different html template for each backend layout and you are running TYPO3 8.7.x there is a different way to solve this issue: Add to your template file a new section called:
This section will be loaded just before the closing of
</body>
. As far as I remember you don't even have to call this section in your layout file.I found another solution, that uses a TypoScript Custom Condition:
First I create a BackendlayoutCondition.php in my Extension here:
Its content is this (See Comments for more Detail):
(Edited 2)
Than I just have to use the following Condition in my
pageSetup.ts
:Now I have this Sourcecode in the Frontend:
not that:
if I use the FooterAssets method:
Edit: I found some errors in my Answer, i fix it and edit my answer then.
Edit2: Now the Condition checks the Backendlayouts and the Backendlayouts_Nextlevel Fields for Backendlayouts to get all possible BE-Layouts including the inherited.
i would opt for using the VHS extension which provides an asset viewhelper.
you than include the asset view helper into the frontend template you are rendering. and it takes care about plaching the javascript in the header / footer it allows also to definde dependancies and loads the script in the correct order. also supports concatination / minification ...
an example include might look like this:
this requires you that you specified "jquery" via typoscript (or another assit view helper)
example typoscript: