Add a static template to my typo3 extension - typo3

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.

Related

How to access data from FLUIDTEMPLATE file and render that content in our desired file?

I have my package from sitepackagebuilder (v9.5.14). I no good at Typoscript. I am using the optional menu navigation file MainBefore.html (my desired file) from bootstrap_package which I put in my stpkg extension because this file is globally available in the FE alongside main menu. I try to explain my doubt in the two following examples.
First one is clear to me. usually I do things like this, (My only known typoscript way to access and render things).
Example 1:
In typoscript
lib.stdContent = FLUIDTEMPLATE
lib.stdContent {
file = EXT:sitepackagebuilder/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
In Data.html
<h4>Hello TYPO3</h4>
<h3 hidden>{mylabel}</h3>
MainBefore.html
....
<div class="from-data-file"><f:cObject typoscriptObjectPath="lib.stdContent" /></div>
....
The above example will work.
Example 2:
But this following example is my doubt.
page.10 = FLUIDTEMPLATE
page.10.variables.userInfoForChat = COA_INT
page.10.variables.userInfoForChat {
10 = FLUIDTEMPLATE
10 {
file = EXT:company/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
}
How can I access variables in Data.html and render content in MainBefore.html like example 1? Correct me If I am wrong
Both files are in same location.
First: you are doing very complicated things. normaly stacking templates inside each other is not necessary. so the main question would be: What do you intend to do?
Then we can find a simple way to do it.
I try to identify your intention:
you have a main template (main = main for this example, otherwise it is just a small part of the general page rendering) where you want to have a variable, which is filled from another template, where some variable is inserted.
Some information is missing as these would not be necessary when all values are static like in your example.
There must be something non static as you use a uncached COA_INT and the name userInfoForChat hints to something user specific, which of course is not cachable.
My question is: why do you put a complete fluid templating in the variable, when it should be enough to have only some uncached values in it and stay with just one set of fluid template. (That set already could consists of template, layout and a lot of partials)

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.

Custom tags in TYPO3 content

new here, and also new to TYPO3.
I need to put something like [imagebox, title='box1'] into content editor and that will be replaced by a text and image with some javascript effect (text and image are managed in the DB elsewhere, the tag is just for the placement in the page).
I've read that TYPO3 has a mechanism for adding custom tags and I managed to make them accepted in the RTE.
I tried instead of [imagebox..... to use
<imagebox>box1</imagebox>
with something like this (copied from web):
tt_content.text.20.parseFunc.tags {
imagebox < lib.parseFunc.tags.link
imagebox = TEXT
imagebox.value= replaced
# imagebox = PHP_SCRIPT
# imagebox {
# stripNL = 0
# Pass a parameter from Typoscript to a PHP script:
# UID of the page containing the SINGLE view of tt_news
# id_singleView = 18
# Call the PHP script
# file = fileadmin/scripts/imagebox_parser.php
# }
}
lib.parseFunc.tags.imagebox < tt_content.text.20.parseFunc.tags.imagebox
should be able to replace content between tags.
I've commented call to php function just tried to get a text replacement for starters.
I've put that in the main root template Setup, but nothing is replaced.
I've also tried other examples from the web with no success.
Did anyone have situation like this?
Are there better approaches for that in TYPO3? (I'm using v7.6.23)
Any suggestion or hint is appreciated.
EDIT: using FSC on textmedia element
I think your examples are outdated. (the object PHP_SCRIPT is obsolete for a long time)
You might have a look at the documentation for your TYPO3 version:
https://docs.typo3.org/typo3cms/TyposcriptReference/7.6/Functions/Parsefunc/
you also need to enhance the parsefunc where you need it. That can depend on:
CSC or FSC?
which kind of content element (CE) do you use? (be sure to enhance the rendering of that CE)

Extend News Administration Backend Module

I would like to have a custom view of the news listing in the backend module.
My own extension has custom layouts and partials but TYPO3 doesn't use them.
setup.txt
module.tx_news {
view {
templateRootPaths.0 = EXT:news_review/Resources/Private/Templates/
partialRootPaths.0 = EXT:news_review/Resources/Private/Partials/
layoutRootPaths.0 = EXT:news_review/Resources/Private/Layouts/
}
Here's my file structure:
file structure
Versions used:
TYPO3 7.6.15
news 5.3.2
Following has been consulted but didn't work for me:
https://stackoverflow.com/a/33775089/7566899 and
https://forge.typo3.org/issues/66306
edit: Fixed the paths (without /Administration/)
templateRootPaths.0 = EXT:news_review/Resources/Private/Templates/Administration/
The news template file paths are appended to this path.
So if news includes Administration/Index.html, the full path would be
EXT:news_review/Resources/Private/Templates/Administration/Administration/Index.html
(double Administration/)
I don't think you wanted that.

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">');