I want to output a string to the rendered HTML by using two fallbacks.
My typoscript is defined at the top level page (root page of my website) and is passed to all pages at lower levels.
Structure:
Homepage
Page at level 1
Page at level 2
Regular output of the file:
The string comes from a TemplaVoila field (Page / Edit / Extended / MyField): field_copyright_name
To output it to the desired point in the HTML output a templaVoila mapping exists (Type: Typoscript Object Path), named: lib.copyright_name
The following typoscript does the job:
lib.hint_copyright_name = COA
lib.hint_copyright_name.10 = TEXT
lib.hint_copyright_name.10 {
setCurrent.dataWrap = {field:field_copyright_name}
current = 1
}
This works for all pages at all levels where the field (in page properties) is not empty.
The first fallback:
If the field is empty (in properties of that page, e.g. at level 2) typoscript should get the value from the pages above (at level 1, and if it is empty too, it should get it from homepage). No clue how to do it. Can you help?
The second fallback
If the first fallback still returns an empty string (because the field was empty at all levels) it should do a fallback to a default value "Copyright by me".
To enable this fallback without "first fallback" is easy:
switchdefault_copyright_name = TEXT
switchdefault_copyright_name {
setCurrent.dataWrap = {field:field_copyright_name}
current = 1
override = "Copyright by me"
override.if.isFalse.field = field_copyright_name
}
lib.hint_copyright_name = COA
lib.hint_copyright_name.10 < switchdefault_copyright_name
But how to integrate the "first fallback"?
EDIT:
I tried:
setCurrent.data = {levelfield:-1, field_copyright_name, slide}
or
setCurrent.data = levelfield:-1, field_copyright_name, slide
or
setCurrent.dataWrap = {levelfield:-1, field_copyright_name, slide}
or
setCurrent.dataWrap = levelfield:-1, field_copyright_name, slide
but without success - no output.
Just found this : http://lists.typo3.org/pipermail/typo3-english/2006-October/032764.html
It's supposed to make youre slide thing to work.
Just set : Installation > all configuration > addRootLineFields
Didn't tried it, but seems like the solution
Related
Is it possible to configure which content element types are available for the content elements relation in tx_news records?
I have a backend layout which allows only gridelements in tt_content. The regular content elements are only allowed within a grid elements container.
Currently I face the problem, that in news records it's only possible to add grid elements:
I'd like to allow only some specific content elements in news records.
Update:
The above mentioned restriction is done via TSConfig for the BackendLayout:
mod.web_layout.BackendLayouts {
1 {
title = Standardseite
config {
backend_layout {
colCount = 1
rowCount = 1
rows {
1 {
columns {
1 {
name = Content
colPos = 0
allowed = gridelements_pi1
}
}
}
}
}
}
}
}
When I remove the line allowed = gridelements_pi1, all content element types are available again.
But regardless of the allowed setting for backend layouts I'd like to have just a small subset of content element types available for news records.
Sometimes the solution can be so simple and obvious! Thx for hint, Georg Ringer!
Just override the settings for the news sys folder:
[45 in tree.rootLineIds]
# this changes the allowed CTypes. Add more as a comma separated list
mod.web_layout.BackendLayouts.1.config.backend_layout.rows.1.columns.1.allowed = textmedia
# this sets the default CType to prevent an error with INVALID VALUE ("text")
TCAdefaults.tt_content.CType = textmedia
[global]
By the way, an even better solution would be to use TCEFORM.tt_content.CType.removeItem = ..., but this would require to update the list each time you add a new CType.
I want to set the Sitename in Constants by default, so I can use this settings.variable in my Fluidtemplate.
I found in another post here on stackoverflow:
DB:sys_template|1|title
GLOBAL:TYPO3_CONF_VARS|SYS|sitename
But if I use this in my constants.ts like this:
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = DB:sys_template|1|title
OR
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
AND in my setup.ts:
testsitetitle = {$plugin.tx_rmnavigation.settings.testsitetitle}
I get only the text not the value of the "variable" see this picture Constant Editor...
How can I use the Sitename in Constants as a defaultvalue?
Edit
I forgot to say, perhaps it's important for this issue, I try this here in both files:
plugin.tx_rmnavigation {
settings {
..
}
}
You have to assign your constant to a content object's data property (see https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/ContentObjects/Index.html and https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Functions/Stdwrap/Index.html#data) to get it resolved:
testsitetitle = TEXT
testsitetitle.data = {$plugin.tx_rmnavigation.settings.testsitetitle}
And I would prefer your second variant for the constant definition because it uses the value from the current template record:
# cat=plugin.tx_rmnavigation/01_NaviSettings/a; type=string; label=testing sitetitle
testsitetitle = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
But the first one should also work if you use colons instead of pipes:
testsitetitle = DB:sys_template:1:title
If you have a multi domain page the query to DB:sys_template:1:sitetitle might not work, as the 1 is the UID, not the PID of the root node of your template. But TSFE to the rescue!
In the context of your page call, the TSFE already has the sitetitle from the backend template loaded.
If you for example want to output a og:site_name, you can access the value by using:
og:site_name = TEXT
og:site_name {
data = TSFE:tmpl|sitetitle
attribute = property
}
This way no additional database queries are needed and it will work on multi domain, multi root node pages.
Thanks for your suggestions. I found a solution with your infos.
Honestly I think this doesn't works in Constants, because the both methods are readonly.
So I found a working solution for my Issue: I need that Variable only for read in my Templates, so I create a new Typoscript File libs.ts and included this with:
# Include Libraries
<INCLUDE_TYPOSCRIPT: source="FILE: EXT:rm_navigation/Resources/Private/TypoScript/libs.ts">
in the /Configuration/TypoScript/setup.ts File.
The content of libs.ts is:
TSFE-Syntax
lib.sitename = TEXT
lib.sitename.data = GLOBAL:TYPO3_CONF_VARS|SYS|sitename
OR
DB-Syntax
lib.sitename = TEXT
lib.sitename.data = DB:sys_template:1:sitetitle
works both. I read that you use the colon-syntax for DB usage and the pipe-syntax for Global Variables.
To get this to Fluid use this Code:
<f:cObject typoscriptObjectPath="lib.sitename" />
I hope it helps Others who also has this Issue.
I'm currently working on my first typo project and need to create a mega menu with an individual set of pages.
Many attempts failed or are not suitable for me. My current shot aims to group pages of the redirect type in a hidden page. In Typoscript I want to set the ID of the parent page containing these redirections and read the shortcut IDs of the children accordingly.
pageIds = CONTENT
pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
}
The next step would be to use the retrieved shortcut IDs in my HMENU of the type 'list'.
1 = HMENU
1 {
special = list
special {
value = # Assign retrieved IDs here
}
[...]
}
Typoscript is very confusing at first sight, so I would be glad to receive some hints how I can transfer the query's result, as a comma-seperated list, to the HMENU.
Thanks in advance!
Greetz.
First, you need to get a comma-separated list of the page UIDs you want to link. This can be achieved with a renderObj:
lib.pageIds = CONTENT
lib.pageIds {
table = pages
select {
selectFields = shortcut
pidInList = 614 # Id of the container Page
}
renderObj = TEXT
renderObj.stdWrap.field = shortcut
renderObj.stdWrap.wrap = |,
}
This should give you a comma-separated list of all records. Now you must apply these to the HMENU. As you can read in the documentation, the value property is stdWrap enabled, this means that you can copy a value when you use a cObject:
1 = HMENU
1 {
special = list
special {
value.cObject < lib.pageIds
}
[...]
}
I didn't test this, so maybe the configuration is not entirely complete.
how can i create a typolink which:
reads it's target from a column in tt_content (like header_link f.e.)
applies a page type to internal links, but obviously not to external links
f.e., given the values 42 and https://x.org in header_link the desired links should look like:
/<path_to_page_id 42>?type=5
https://x.org
i can't figure out how to apply the page type on the condition internal/external link. this is what i got:
text = TEXT
text.value = click here ;-)
text.stdWrap.typolink {
parameter.field = header_link
# following line should only apply if `header_link` is an internal link
parameter.wrap = |,5
}
edit to clarify:
above code produces:
/<path_to_page_id 42>?type=5
https://x.org,5 <-- not what i want
how do i get the page type for internal links and leave external links untouched?
Documentation to the TSREF for typolink
http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
adding a page type:
lib.sampleLink = TEXT
lib.sampleLink.value = Open Page 25 with Type 800 in a new window
lib.sampleLink.typolink.parameter = 25,800 _blank
Can I create a "special" type of tt_content, so text is beeing processed in some custom ways before outputtet?
In my case I would like to add ###MY_MARKER### somewhere in header and/or bodytext and have it replaced by the right words for the given page.
eg:
When visiting this page: mypage.com/?marker=test
Header in tt_content: "Welcome to ###MY_MARKER##, enjoy
Output in browser: "Welcome to TEST, enjoy"
I CAN do it by making a custom plugin. Question is more if I can reuse normal tt_contant for the same purpose
Yes, you can easily extend the tt_content by adding your own TCA configuration to the typo3conf/extTables.php file:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['CType']['config']['items']['user_my_type'] = array(
0 => 'My custom content',
1 => 'user_my_type',
2 => 'i/tt_content.gif',
);
$TCA['tt_content']['ctrl']['typeicon_classes']['user_my_type'] = 'mimetypes-x-content-text';
$TCA['tt_content']['ctrl']['typeicons']['user_my_type'] = 'tt_content.gif';
/* In the following either copy, insert and modify configuration from some other
content elemenet (you can find it in the ADMIN TOOLS -> Configuration - $TCA)... */
$TCA['tt_content']['types']['user_my_type']['showitem'] = '';
/* ...or assign it some other configuration so that it's exactly the same
as some other content type and stays the same after some update of TYPO3: */
$TCA['tt_content']['types']['user_my_type']['showitem'] = $TCA['tt_content']['types']['text']['showitem'];
After that, just set in your Typoscript template how the element is supposed to be rendered:
tt_content.user_my_type = COA
tt_content.user_my_type {
10 = TEMPLATE
10 {
template = TEXT
template.field = header
marks {
MY_MARKER = TEXT
MY_MARKER.value = TEST
}
}
20 = TEMPLATE
20 {
template = TEXT
template {
field = bodytext
required = 1
parseFunc = < lib.parseFunc_RTE
}
marks < tt_content.user_my_type.10.marks
}
}
NOTES
The Typoscript rendering is just a simplified example. You might want to add other standard configuration like in other elements, e.g. the one that adds edit icons for frontend display.
The marker in my example can be populated by the value of a GET paramater in the URL as you wanted but this would have nasty security implications. You would certainly need very good validation of that input.