Extbase storagePid with levelfield - typo3

I try to set the the storagePid of an extbase plugin by using levelfield like this:
plugin.tx_myext.persistence.storagePid = TEXT
plugin.tx_myext.persistence.storagePid.data= levelfield: -1, storage_pid, slide
Using the storage_pid of the current page is no problem:
plugin.tx_myext.persistence.storagePid = TEXT
plugin.tx_myext.persistence.storagePid.data= page:storage_pid
But I want to use levelfield to improve the usability of an extension. Thus you only would have to setup the storage_pid in the root page and include the default typoscript setup for the extension, which uses levelfield, into the root template...
Does anybody have a clue why levelfield is here not working?

Not all fields can be used by default with levelfield. The fields that can be used on scratch are defined in $TYPO3_CONF_VARS["FE"]["addRootLineFields"]
To add another field simply add
$GLOBALS["TYPO3_CONF_VARS"]["FE"]["addRootLineFields"] .= ",storage_pid";
in typo3conf/ext_tables.php or in the ext_tables.php of your extension.

Related

Add a static template to my typo3 extension

I have created an extension with sitepackagebuilder.com and the idea is just to write some static html.
I know that when you have a controller you can call the templates by following the convention names. But what if you don't have a controller? What I need, at least for now, is just to install the extension, add the plugin into a page and get some static content in that page.
I can imagine that this is set in a typoscript file but I'm quite noob with all the typoscript thing.
I'm getting this error:
'No Content Object definition found at TypoScript object path "tt_content.list.20.heboorganigram_organigram"'
Until I define that object in my typoscript file. I have tried this.
tt_content.list.20.heboorganigram_organigram = PAGE
tt_content.list.20.heboorganigram_organigram.10 = TEMPLATE //(or FLUIDTEMPLATE same result)
tt_content.list.20.heboorganigram_organigram.10.template = FILE
tt_content.list.20.heboorganigram_organigram.10.template.file = fileadmin/Organigram.html
And then I don't get an error but I also don't get the content from my Organigram.html, this is just trying stuffs, I actually don't know if this is what I need to do.
Before creating new Content Elements you first have to create the Page Template, for that have a look at the sitepackage tutorial https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/FluidTemplates/Index.html
If you already got the page template, have a look at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html
Provided you already did the steps above, for getting the frontend output you are interested in the step Configure the frontend rendering
So the TypoScript should look something like this:
lib.contentElement {
templateRootPaths.200 = EXT:heboorganigram/Resources/Private/Templates/
}
tt_content {
examples_newcontentelement =< lib.contentElement
examples_newcontentelement {
templateName = NewContentElement
}
}
Then you need to place your Organigram.html file in the Templates Folder in inside the sitepackage.

setup.txt / setup.typoscript not being loaded in module

I'm writing an extensio in Typo3 9.5 and I can't get the setup.txt or setup.typoscript to load.
I am trying to add a second page type that renders only JSON. For that I gather I need to change the typoscript. Therefore I added this code to my setup.typoscript:
ajax_ajaxjson = PAGE
ajax_ajaxjson {
typeNum = 1
config {
disableAllHeaderCode = 1
additionalHeaders = {
10 {
header = Content-Type: application/json
replace = 1
}
}
xhtml_cleaning = 0
debug = 0
no_cache = 1
admPanel = 0
}
10 < tt_content.list.20.tx_energieportal_ajaxjson
}
(in EXT:\Configuration\TypoScript\setup.txt)
Now when trying to load that page type, I get the following error:
TYPO3\CMS\Core\Error\Http\ServiceUnavailableException
The page is not configured! [type=1][]. This means that there is no TypoScript object of type PAGE with typeNum=1 configured.
I also added a test variable, and when rendering that variable with
<f:cObject typoscriptObjectPath="testvar"/>
I get the error:
No Content Object definition found at TypoScript object path "testvar"
I setup my sys_template.php up like this:
<?php
defined('TYPO3_MODE') or die();
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'energieportal',
'Configuration/TypoScript',
'Energieportal Frontend'
);
(in EXT:\Configuration\TCA\sys_template.php).
I also tried renaming the setup.txt to setup.typoscript.
Is there anything else I need to do to have my module load the setup.typoscript? I looked at the docs and other modules, but I couldn't find anything for setting up that file.
I used the search function, but the only similar question wasn't really answered. (Link)
If you want to override the TCA of existing tables, you need to put the file into Configuration/TCA/Overrides/.
So, the correct path for your sys_template.php needs to be Configuration/TCA/Overrides/sys_template.php.
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile only adds it to the list of static TypoScript files which can be loaded in a TypoScript template. It does not load the TypoScript file automatically.
You will have to include it in a TypoScript template in the TYPO3 backend. You can find the available static templates in the Includes tab under Include static (from extensions).
Alternatively you can include it in a different TypoScript file that is already loaded in the previously mentioned way using #import 'EXT:EXT:energieportal/Configuration/TypoScript/setup.typoscript' or <INCLUDE_TYPOSCRIPT: source="FILE:EXT:energieportal/Configuration/TypoScript/setup.typoscript">
It is also possible to add TypoScript directly from PHP using \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript('My TypoScript'), so you can add the #import or <INCLUDE_TYPOSCRIPT...> line there. You can add this in your extension's ext_localconf.php or Configuration\TCA\Overrides\sys_template.php. It is however usually not recommended as you might not want the TypoScript loaded for all pages and/or sites in a TYPO3 installation.

Change label of flexform select item in TYPO3 extension tx_news

I want to add a new sorting option to the flexform in the frontend plugin of the TYPO3 extension tx_news. This works fine so far with these additions:
ext_tables.php of my theme extension:
$TYPO3_CONF_VARS['EXT']['news']['orderByNews'] .= ',archive';
TypoScript configuration within my theme extension:
plugin.tx_news.settings.orderByAllowed := addToList(archive)
What I miss now is the possibility to change the label of the new item archive in the select field Sort by of the flexform.
I assume it is done via page TSconfig and TCEFORM.tt_content.pi_flexform.news_pi1.sDEF.settings.orderBy but I can't figure out exactly how.
TYPO3 version is 6.2
This did the trick for me:
TCEFORM.tt_content.pi_flexform.news_pi1.sDEF.settings\.orderBy.altLabels.archive = LLL:EXT:my_theme/pathto.xlf:archive
It's important to escape the dot before the fieldname!
I never tried to use pageTS to localize (only template TS), so I don't know if it is actually possible. I would however suggest localizing the label using the locallang files, in this case creating locallang_db.xlf in appropriate path in typo3conf/l10n/ with localization for tx_news_domain_model_news.archive label.
More info here: https://wiki.typo3.org/Translations#Translation_internals.2C_how_does_it_work.3F

How to rename subheader in TYPO3 CMS backend

How can I rename a TYPO3 CMS backend field for authors? i.e. the mentioned field for content-elements of csc_styled_content?
In general, overriding label names can by done with Page TSconfig in the backend. The following example modifies the label of the subheader field.
TCEFORM {
tt_content {
subheader.label = My new Label-Name
}
}
There are two way to configure that adjustment in TYPO3.
Type your configuration changes directly to the page settings » resources » TypoScript Configuration » Page TSConfig (see the screenshot below)
as an alternative you can store that configuration directly in the file system - either in your custom extension (e.g. at typo3conf/ext/my_extension/Configuration/TSconfig/labels.t3s) or with a similar name in the global file storage (e.g. fileadmin/templates/configuration/...)
That's basically it to provide custom labels for any database table in the TYPO3 backend. Find more aspects that can be adjusted in the accordant Page TSconfig documentation.
If you want to rename a field of an extension like tx_news you could do it this way.
TCEFORM {
tx_news_domain_model_news {
title.label = Your New Label
}
}
Now there are two ways to get this to work:
Put it in Page TSConfig of the page settings
OR
Load it with your extension from a file (e.g. EXT:my_extension/Configuration/pageTSConfig.typoscript). For that you have to import this script by EXT:my_extension/ext_localconf.php!
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_extrension/Configuration/pageTSConfig.typoscript">');

TYPO3 Powermail 2 - how change template for plugin instance

I have Powermail( new version, the one based on Extbase) instance at the bottom of each page. This instance is placed somewhere on the website and rendered in footer via RECORDS.
Now, I need this instance to have different templates than the rest of Powermail plugin instances.
So, how can I pass this configuration to the plugin instance? There is no option in flexform to specify the path to the template so I'm stuck.
Thanks in front ;)
You can use an extension template on the respective page, and set the templateRootPath accordingly - either by setting the constants plugin.tx_powermail_view.templateRootPath or by setting the setup settings plugin.tx_powermail.view.templateRootPath directly:
plugin.tx_powermail {
view {
templateRootPath = {$plugin.tx_powermail.view.templateRootPath}
partialRootPath = {$plugin.tx_powermail.view.partialRootPath}
layoutRootPath = {$plugin.tx_powermail.view.layoutRootPath}
}
}
(partials and layout follow the same pattern)
See: http://typo3.org/extension-manuals/powermail/2.0.0/view/1/48/
You can set a different layout for this in the "Extended" Tab of the form, as described here:
http://docs.typo3.org/typo3cms/extensions/powermail/Powermail/Faq/Index.html#how-to-change-the-style-selector-with-my-own-values-in-forms-pages
This way a class will be set in the < form >-tag, und you may style the record differently.