TYPO3 Update to 8.7 Template not working - typo3

I try to update an Typo3 Installation from 6.1 to 8.7 LTS but i dont get the templates working.
What i did so far:
Updated the core to 6.2 -> 7.6 -> 8.7
Updated all the Extensions as possible
The old installation used Fluid Pages Engine but this is not available for 8.7. As far as i understand it, fluid is now included in typo3?
Backend is working so far. I can administrate users, Pages and everything i looked at. However, when i call the frontend, i get an Exception:
#1294587217: The page is not configured! [type=0][]. This means that there is no TypoScript object of type PAGE with typeNum=0 configured.
TYPO3\CMS\Core\Error\Http\ServiceUnavailableException thrown in file
...\typo3_src-8.7.10\typo3\sysext\frontend\Classes\Controller\TypoScriptFrontendController.php in line 2487.
I tried the solution from the wikipage and replaced the "setup"-Template information
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/typoscript/domain.ts">
<INCLUDE_TYPOSCRIPT: source="FILE:fileadmin/typoscript/typoscript.ts">
page.stdWrap.parseFunc.short.i3 = <span style="text-transform:normal;">i3</span>
with
# Default PAGE object:
page = PAGE
# Define output for typeNum=0, the default type.
page.typeNum = 0
page.10 = TEXT
page.10.value = HELLO WORLD!
Then i see "HELLO WORLD!". Now i stuck: what do i have to do to get the "normal" template working?
Thanks in advance

TYPO3 7 and 8 both include the FLUIDTEMPLATE Typoscript object, but EXT:fluidpages is an external extension mantained by the fluidtypo3.org team.
As you wrote:
# Default PAGE object:
page = PAGE
# Define output for typeNum=0, the default type.
page.typeNum = 0
page.10 = TEXT
page.10.value = HELLO WORLD!
You are defining that the PAGE object will contain only that simpe TEXT object.
A "minimum" configuration to use the FLUIDTEMPLATE object would be:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10{
templateName = Default
layoutRootPaths {
0 = Path/To/Your/Layouts/
}
partialRootPaths {
0 = Path/To/Your/Partials/
}
templateRootPaths {
0 = Path/To/Your/Templates/
}
}
which means that you are using an Default.html template
to use different templates, you should also configure some backend layouts; assuming that you are using the database to store them the previous code could become:
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10{
templateName= TEXT
templateName.stdWrap {
cObject = CASE
cObject {
key.data = levelfield:-2,backend_layout_next_level,slide
key.override.field = backend_layout
default = TEXT
default.value = Default
//these are the IDs of the backend_layout records in DB
1 = TEXT
1.value = Default
2 = TEXT
2.value = Home
//add other values
}
ifEmpty = Error
}
layoutRootPaths {
0 = Path/To/Your/Layouts/
}
partialRootPaths {
0 = Path/To/Your/Partials/
}
templateRootPaths {
0 = Path/To/Your/Templates/
}
}
See also: https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html
If you need further help I could suggest you to join the typo3 Slack channel (subscribe here: https://forger.typo3.com/slack) and join the typo3-cms channel and the fluidtypo3 channel.

I think your typoscript file is not included in ROOT Template.
First of copy all typoscript in the typoscript.ts file and paste in the setup.ts in ROOT Template and after check the frontend. If every thing is fine then definitely your typoscript is not included on ROOT template and if this is not working then some mistake in your typoscript object

Related

How to prevent TYPO3 to render head- and body-elements when outputting JSON?

In TYPO3 8.7 I'm trying to generate JSON using FLUID.
I've created a page with dummy content and I've updated my TypoScript configuration for all pages in a folder.
TypoScript setup
[PIDinRootline = 10]
page = PAGE
page {
typeNum = 0
config {
disableAllHeaderCode = 1
disablePrefixComment = 1
xhtml_cleaning = none
admPanel = 0
debug = 0
metaCharset = utf-8
additionalHeaders = Content-Type:text/json;charset=utf-8
}
}
[global]
I created a dummy JSON file as well, to test the output, before creating the actual content using FLUID:
api.json
{
"hello": "world"
}
Now, this seems to work fine. But the output still includes the html- and body-elements.
Rendered output:
<html>
<head></head>
<body>
{"hello": "world"}
</body>
</html>
The documentations says:
If you want to output JSON, RSS or similar data with Fluid,
you have to write the appropriate TypoScript which passes the
page rendering to Extbase and Fluid respectively. Otherwise,
TYPO3 will always generate the <head>- and <body>-section.
But I don't know what to do here actually. How can I get TYPO3 to not render the wrapping HTML-elements?
The problem was a new syntax in TYPO3 8 and newer. In newer versions, the additionalHeaders is no longer just a TEXT but an array with numeric indices. So to set the correct header type, you have to use this one:
additionalHeaders.10.header = Content-Type:application/json;charset=utf-8
When you override the page object, you should remove all inside it before with page >.
Additionally Fluid is a templating engine for HTML, I don't know if that fits for JSON output.
Better way:
I'd suggest to use a separate object than page and a different page type:
[globalVar = GP:type = 133]
jsonOutput = PAGE
jsonOutput {
typeNum = 133
config {
...
}
}
[global]
What you are missing is this typoscript:
config.disableAllHeaderCode = 1
read the manual
as you want it on a special page you can use a special typoscript template for this page. For a pagetype it is a little more complicated as this configuration would work on all pagetypes.
if you want some config options only for a special pagetype you can add this config to the pagetype only like this:
json = PAGE
json.config.disableAllHeaderCode = 1
Be aware that fluid is more complicated if you output other structure than HTML. But it is possible! Have a special look on whitespace and braces ({})

How to output COA_INT in fluid template form element

I'd like to pass an extension GP variable to a form that I built outside of the plugin. When trying to do so, I used a COA_INT which turned out to output <INT_SCRIPT. instead of the value.
In order to do so, I built this typoscript object:
lib.gpSWord = COA_INT
lib.gpSWord {
# Protects from XSS!
stdWrap.htmlSpecialChars = 1
10 = TEXT
10 {
stdWrap.data = GP:tx_indexedsearch_pi2|search|sword
}
}
and then tried to output it like this (as suggested here:
<f:form.textfield name="search[sword]" value="<f:format.raw>{f:cObject(typoscriptObjectPath: 'lib.gpSWord')}</f:format.raw>" id="tx-indexedsearch-searchbox-sword" class="tx-indexedsearch-searchbox-sword font-h2" />
And also tried building up the variable before hand using f:variable but nothing worked.
The expected result would be that the variable would be set and the value would then be passed to the form.textfield viewhelper but appearently this does'nt work either.
You should commit the variable in Typoscript (setup) with:
page.10 = FLUIDTEMPLATE
page.10.variables.gpSWord < lib.gpSWord
Then you are able to use it in you Fluidtemplate with:
<f:format.raw>{gpSWord}</f:format.raw>
lib.gpSWord = COA_INT
lib.gpSWord {
stdWrap {
wrap = &tx_indexedsearch_pi2[sword]=|
data = GP:tx_indexedsearch_pi2|sword
if.isTrue.data = GP:tx_indexedsearch_pi2|sword
}
}
Try this for GP.

Typo3 GP Variables in Form

I created a COA_INT like this:
lib.linguasitoparametrol = COA_INT
lib.linguasitoparametrol {
10 = TEXT
10.stdWrap.data = GP:L
}
I print in fluid like so:
Value = {f:cObject(typoscriptObjectPath: 'lib.linguasitoparametrol')}
Result is: Value = 0 or Value = 1.
Ok it works.
Now i want to write the variable in a input area so i write:
<f:form.textarea name="search[languageUid]" value="{f:cObject(typoscriptObjectPath: 'lib.linguasitoparametrol')}" />
But i obtain in input value <!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c-->
Why? how can i solve it?
The <!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c-->should only displayed if you do not cache the page witch contain your template.
<!--INT_SCRIPT.5e0cf67ea790e31ff7adaa744a7a992c--> Is an placeholder for you content that is replaced after cache has build.
You dont need for GP:L a COA_INT object: When you have multiple languages you have allready typoscript conditions for these. So your Cache is build for each of these. The Cache for L=1 is allways different than the cache for L=2.
I would recommend to use it without use of COA:
lib.linguasitoparametrol = TEXT
lib.linguasitoparametrol.data = GP:L
Alternative if you use it in an Fluid Template you can pass the information via variables:
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
template = FILE
template.file = fileadmin/templates/MyTemplate.html
partialRootPath = fileadmin/templates/partial/
variables {
currentLangUid = TEXT
currentLangUid.data = GP:L
}
}
And use it in your Fluid Template by {currentLangUid}, so you dont have to use the cObject Viewhelper.

How to set TYPO3 7 metatags from TypoScript RECORDS?

I'm trying to override the page.meta.og:title in TYPO3 7.5 with a TypoScript RECORDS object.
The following TypoScript snippet does not seem to work unfortunately:
[globalVar = GP:tx_myext_pi1|article > 0]
temp.newsTitle = RECORDS
temp.newsTitle {
dontCheckPid = 1
tables = tx_myext_domain_model_article
source.data = GP:tx_myext_pi1|article
source.intval = 1
conf.tx_myext_domain_model_article = TEXT
conf.tx_myext_domain_model_article {
stdWrap.field = title
stdWrap.wrap = |
}
}
# Overrides the template pageTitle
page.10.variables.pageTitle >
page.10.variables.pageTitle < temp.newsTitle
# Overrides the meta og:title
page.meta.og:title >
page.meta.og:title < temp.newsTitle
[global]
I get:
<meta name="og:title" content="RECORDS">
While the override of the page title works for me.
Are there any ways to achieve this with TypoScript?
RECORDS only works within a cObject.
https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Records/Index.html
[globalVar = GP:tx_myext_pi1|article > 0]
page.meta{
og:title {
attribute = property
stdWrap.cObject = RECORDS
stdWrap.cObject {
source = {GP:tx_myext_pi1|article}
source.insertData = 1
tables = tx_myext_domain_model_article
conf.tx_myext_domain_model_article= TEXT
conf.tx_myext_domain_model_article.field = title
}
}
[global]
While it's your ext what prevents you from adding it directly within action instead of manipulating with some weird TS? ;)
public function showAction($article) {
$ogTitle = trim(htmlentities($article->getTitle()));
$GLOBALS['TSFE']->getPageRenderer()->addMetaTag('<meta name="og:title" content="' . $ogTitle . '">');
// ... rest of action
}
Also take a look to Georg Ringer's News extension to see how he uses metaTagViewHeplper (actually he's doing the same but in VH) - you can use it to collect other og tags on the view like og:image and others.
Edit:
(More about preventing duplicated entries)
Keep in mind that duplicated meta combinations it's not a bug, it's a feature according to OGP Arrays spec ;) Actually fact that you can not declare two same meta tags with TypoScript is a bug, reason? TypoScript is not a programming language, it's just configuration table (array to be strict). As we know in PHP in associative array later key overrides earlier. While we're in topic of og:* metas we need to remember that sometimes they are repeated per page and it's perfectly valid, i.e: og:image.
You as a programmer has much more power within your action than in TS, even if you are using some ready-to-use ext which fills og:title from the pages records, nothing prevents you from discarding it with ... simple trick in TS, in your TS add a condition:
[globalVar = GP:tx_myext_pi1|article > 0]
page.meta.og:title >
[end]
and then make sure that you're adding it in your showAction as showed at the beginning.
Finally this way you do not need to make expensive lookup from TS site for each model that has a single view (believe me I know what that means)
BTW, I agree that there should be solid API for this, but I wrote some ext for one of my project for these things, that was matter of hours not even days, if I'll find it, I'll publish it to TER.
I was to quick with posting my question :)
It could be achieved by using the register, here is a example:
[globalVar = GP:tx_myext_pi1|article > 0]
page.9 = LOAD_REGISTER
page.9 {
newsTitle.cObject = RECORDS
newsTitle.cObject {
dontCheckPid = 1
tables = tx_myext_domain_model_article
source.data = GP:tx_myext_pi1|article
source.intval = 1
conf.tx_myext_domain_model_article = TEXT
conf.tx_myext_domain_model_article {
stdWrap.field = title
stdWrap.wrap = |
}
}
}
page.10.variables.pageTitle >
page.10.variables.pageTitle = TEXT
page.10.variables.pageTitle {
data = register:newsTitle
}
page.meta.og:title >
page.meta.og:title {
attribute = property
override.data = register:newsTitle
}
[global]

Build HMENU with Information from TCE

I have extended the TCA for every Backend-Page on the Page-Tree. One of the new Options is the "Page-Type", for example "PressPage". With this Extension, i have a new databasefield in the table "pages".
Now i would build an HMENU/TMENU with all pages, below this folder.
[...]
lib.MetaPressNavigation{
special = directory
special.value = ID_FROM_FOLDER_WITH_PAGETYPE_PRESSPAGE
[...]
But i have no idea to realize them with typoscript.
I hope anyone can help me.
Thanks.
EDIT:
Now - i have try it with an extended TCA. It's very easy for any User to make some configuration for this projectpage. The Users can set a value with an Checkbox in a special tab.
I have try to get the page out form the database, with this special config - any page have in the database on the column "tx_meta_pagetype the value 9. I need the UID from this page to build the META-Navigation. It will be full functional - when i give a hardcoded uid, but i need this dynamic.
This is my attemp, to get the UID from the database:
temp.MetaNavigationIds = CONTENT
temp.MetaNavigationIds{
table = pages
select.Where = tx_meta_pagetype = 9 #tx_meta_pagetype is set from the TCA
renderObj = TEXT
renderObj.field = uid
renderObj.stdWrap = |
}
lib.MetaNavigation = HMENU
lib.MetaNavigation{
special = directory
special.value < temp.MetaNavigationIds #the UID of configured page, that i need for the menu
1 = TMENU
1 {
wrap = <ul> | </ul>
NO{
wrapItemAndSub = <li> | </i>
wrapItemAndSub.insertData = 1
allStdWrap.insertData = 1
}
}
}
I have try a lot of database question with typoscript, but nothing works.
Be careful, special.value is not a content object but just a property. You are copying a content object (CONTENT) in its place. This does not work.
However it does have stdWrap. Therefore something like
special.value.stdWrap.cObject < temp.MetaNavigationIds
Should work out.
For renderObj.stdWrap = | enter renderObj.wrap = |, instead. Please mind the trailing comma. This will make sure that you actually get a comma separated list of uids. Otherwise your uids would be printed just after each other, thus forming one big number.
Please test each part individually before adding the components together. You should make sure that each pease returns the correct data, otherwise you will never get a working solution.
And of course select.Where must be select.where. Capitalization does matter.
Here is a working example for CONTENT:
page.10 = CONTENT
page.10 {
table = pages
select {
where = doktype = 199
recursive = 99
# Needs to be your root page uid
pidInList = 1
}
renderObj = TEXT
renderObj.field = uid
renderObj.wrap = |,
}
If you are using TYPO3 6.2, I would recommend to use the new category system. You can create different categories in the TYPO3 backend and assign those categories to your pages.
With this, you can create a HMENU/TMENU like shown below:
20 = HMENU
20 {
special = categories
special.value = 1,2
1 = TMENU
1.NO {
...
}
}
If you do not use TYPO3 6.2 or do not want to use the category system, you can use a userfunction to return the pages which matches your "Page-Type".
HMENU/TMENU TypoScript will be like shown below.
lib.leftmenu.20 = HMENU
lib.leftmenu.20.special = userfunction
lib.leftmenu.20.special.userFunc = user_myspecialmenu_pi1->getPressPages
The TypoScript above is just an example, and you need to code the userfunction your own.
A detailed reference of the special property userfunction is available here and a example can be found here.