my output is a simple MenuProcessor like this:
tt_content.content_element_overview_navigation =< lib.contentElement
tt_content.content_element_overview_navigation {
templateName = OverviewNavigation
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
}
}
and the Fluid Output work also fine:
lib.overviewContentNavigation = COA
lib.overviewContentNavigation {
20 = COA
20 =< tt_content.content_element_overview_navigation
}
Fluid Output:
<f:cObject typoscriptObjectPath="lib.overviewContentNavigation" />
But now, i need the output only in the treeLevel 5.
My Test:
[tree.level == 5]
lib.overviewContentNavigation = COA
lib.overviewContentNavigation {
20 = COA
20 =< tt_content.content_element_overview_navigation
}
[end]
If the tree.level / typoscriptObjectPath is empty, then I get an error in the frontend.
How can i check the empty output?
Dont work:
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.overviewContentNavigation')}">
<f:cObject typoscriptObjectPath="lib.overviewContentNavigation" />
</f:if>
You need the object path every time, so only add the content when condition is met. I would give this a try:
lib.overviewContentNavigation = COA
lib.overviewContentNavigation.20 = COA
[tree.level == 5]
lib.overviewContentNavigation {
20 =< tt_content.content_element_overview_navigation
}
[end]
Related
I try to get the children to the actual page.
This is my best try:
10 {
dataProcessing {
100 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
100 {
levels = 1
entryLevel = page:level
includeSpacer = 1
includeNotInMenu = 0
as = children
expandAll = 0
}
}
}
I tried to get the menu level of the current page, but I couldn't find something in the documentation that is helping.
Do you have an idea?
My goal is to create a menu for all subpages at the next level.
Thank you for your time :-)
Adjusted solution:
10 {
dataProcessing {
100 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
100 {
as = children
special = directory
special.value.field = pages
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
props #Thomas Löffler
Danke ;-)
there is a content element in TYPO3 named "menu of subpages" which is integrated in TypoScript as well.
What I got from the core (https://github.com/TYPO3/typo3/blob/main/typo3/sysext/fluid_styled_content/Configuration/TypoScript/ContentElement/MenuSubpages.typoscript):
tt_content.menu_subpages =< lib.contentElement
tt_content.menu_subpages {
templateName = MenuSubpages
dataProcessing {
10 = menu
10 {
special = directory
special.value.field = pages
dataProcessing {
10 = files
10 {
references.fieldName = media
}
}
}
}
}
If you don't want to display any images you can remove the files part.
Beware that the example is taken from latest version. There you can replace the dataprocessor class names.
I've created a new fluid menu element and I need it to show an image for each page. The image is stored in the page resources.
When I debug the template, each menu item shows data.media => 1 but media cannot be expanded any further. How can I get the image to render in my template?
TS:
ext_menu_image < lib.contentElement
ext_menu_image {
templateName = MenuImage
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
levels = 1
as = menuItems
expandAll = 1
titleField = nav_title // title
}
}
}
Template:
<f:for each="{menuItems}" as="page">
{f:uri.image(image:page.data.media.???)}
</f:for>
By default the MenuProcessor just puts the data directly from the table into the array in Fluid. The media field in the pages table, just holds the number of relations. So you need another data processor so it is translated to a file. This should do it:
ext_menu_image < lib.contentElement
ext_menu_image {
templateName = MenuImage
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = pages
levels = 1
as = menuItems
expandAll = 1
titleField = nav_title // title
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
}
}
}
I'm running a Typo3 v9.5.4 Onepager style Website. The content is loaded directly from the tt_content. The Website has two FE languages (German/English).
I have a CTA button which has an anchorlink. The button is create with typoscript. I created one button for the German version and one for the English verson bc they have another value and another ancorlink.
I'm not sure if I can access a tt_content field directly from a fluid viewhelper. This is my code i've tried
<f:if condition="{tt_content.sys_language_uid} == 1">
<f:then>
<f:format.raw>{buttonEn}</f:format.raw>
</f:then>
<f:else>
<f:format.raw>{buttonDe}</f:format.raw>
</f:else>
</f:if>
This is my Typoscript for the two button Objects
lib.buttonDe = TEXT
lib.buttonDe {
value = German Text
stdWrap.typolink.parameter = #anchorlinkDE
stdWrap.typolink.ATagParams = class="button"
}
lib.buttonEn = TEXT
lib.buttonEn {
value = English Text
stdWrap.typolink.parameter = #anchorlinkEN
stdWrap.typolink.ATagParams = class="button"
}
And this is the typoscript that loads the Content, the Languages Menu and the Fluidtemplate (the Onepager Content is loaded without a Fluidtemplate, it loads the content directly from tt_content):
//--------------------- One Pager Content
lib.sectionContent = HMENU
lib.sectionContent {
excludeUidList = 12,13,16,17,29
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap >
stdWrap {
cObject = COA
cObject {
if.value = 4
if.equals.field = doktype
if.negate = 1
10 < temp.titleSectionId
10.wrap = <section id="|">
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
orderBy = colPos,sorting
# Only selects Content where CE Layout is 0
where = (tt_content.layout = "0")
}
wrap = <div class="container">|</div>
renderObj < tt_content
}
30 = TEXT
30 {
wrap = </section>
}
}
}
}
}
}
//---------------------
// Language Selector
lib.langmenu = HMENU
lib.langmenu {
special = language
addQueryString = 1
special.value = {$config.language.uids}
1 = TMENU
1 {
wrap = <ul class="dg-langmenu row">|</ul>
NO = 1
NO {
stdWrap.current = 1
stdWrap.setCurrent = {$config.language.labels}
allWrap = <li class="col s6">|</li>
}
ACT < .NO
ACT.doNotLinkIt = 1
ACT.allWrap = <li class="act col s6">|</li>
}
}
page = PAGE
page{
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap{
cObject = TEXT
cObject{
data = levelfield:-2,backend_layout_next_level,slide
override.field = backend_layout
split {
token = pagets__
1.current = 1
1.wrap = |
}
}
ifEmpty = onePager
}
templateRootPaths {
10 = {$path.privat}Templates/
}
layoutRootPaths {
10 = {$path.privat}Layouts/
}
partialRootPaths {
10 = {$path.privat}Partials/
}
variables{
buttonDe < lib.buttonDe
buttonEnd< lib.buttonEn
}
}
So I'd like to load the buttonEn if the content has the sys_language_uid 1 (English) else I want it to load the buttonDe.
Do I need to create an Typoscript Object and then load this Object into the f:if viewhelper? If so how do I create this Typoscript Object.
Thanks for your help!
The easy way (pure typoscript)
lib.button = TEXT
lib.button {
value = English text
lang.de = Deutscher Text
stdWrap.typolink.parameter = #anchorlinkDE
stdWrap.typolink.ATagParams = class="button"
}
[siteLanguage("locale") == "en_EN.UTF-8"]
lib.buton.stdWrap.typolink.parameter = #anchorlinkEN
[global]
but the professional solution is configuring your labels in a language file (see answer from Thomas Löffler) and use:
lib.button = TEXT
lib.button {
lib.button.data = LLL:EXT:site_extension/Resources/Private/Language/locallang.xlf:button_label
stdWrap.typolink.parameter = #anchorlinkEN
stdWrap.typolink.ATagParams = class="button"
}
[siteLanguage("locale") == "de_DE.UTF-8"]
lib.buton.stdWrap.typolink.parameter = #anchorlinkDE
[global]
For language dependent constant data you might use typoscript conditions to redefine a value for your non default languages. (or define a fallback and conditions for each language.)
You should use a locallang file and refer to it in TypoScript.
Create a locallang file (copy an existing and remove all values) named locallang.xlf
Add your english label in there
Create a locallang file in the same folder with prepending de. in the filename (de.locallang.xlf) and add the german label
Refer to it in the TypoScript by using lib.button.data = LLL:EXT:your_ext/path/to/locallang/locallang.xlf:buttonLabel, see https://docs.typo3.org/typo3cms/TyposcriptReference/DataTypes/Index.html#lll
This TS getText function gets the label depending on the set language ID automatically and you only need one TS for the button.
Example: https://docs.typo3.org/typo3cms/TyposcriptIn45MinutesTutorial/UsingGetText/Index.html
In below TYPO3 script code get pages list from others menu item
I want to set order by latest pages with a limit parameter(limit=5)
special directory include submenu entries and display it at home page
[page|uid = 1]
lib.content_6.stdWrap.preCObject = HMENU
lib.content_6.stdWrap.preCObject {
1 = TMENU
wrap = <div class="wpContentElement wpReferenceList"><ul>|</ul></div>
special = directory
special.value = 94,95,97,378,445
includeNotInMenu = 1
special.range = 1|-2
1 {
NO.wrapItemAndSub = <li class="col-xs-12 col-sm-6 col-lg-3 col-xl-3">|</li>
NO.stdWrap.cObject = COA
NO.stdWrap.cObject {
10 = TEXT
10 {
field = title
wrap = <div>|</div>
}
20 = FILES
20 {
references {
table = pages
uid.field = uid
fieldName = tx_mask_referenceimage
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
file.height = 850c
file.width = 850c
}
}
}
}
}
[end]
Maximum can be done with maxItems, but there is no option for your own ordering. You might be able to abuse additionalWhere.
A cleaner solution would be to implement an own itemArrayProcFunc.
1 = TMENU
1 {
maxItems = 5
// additionalWhere = ORDER BY tstamp desc
itemArrayProcFunc = user_menuItemArrayProcFunc->process
}
I'm using gridelements as an extension, but I'm sure this doesn't matter regarding my question.
I have an element like:
tt_content.gridelements_pi1.20.10.setup {
1 < lib.gridelements.defaultGridSetup
1 {
columns {
10 < .default
10.wrap = <div class="class1">|</div>
}
wrap = <div class="class3"><div class="class2">|</div></div>
}
}
What I want to achieve is to insert a menu, which will exist as a Typoscript object at this place:
wrap = <div class="class3"><div class="class2">[>>MENU<<]|</div></div>
I tried this:
wrap.cObject = COA
wrap.cObject {
10 = TEXT
10.value = <div class="class3"><div class="class2">
20 < temp.menu
30 = TEXT
30.value = </div></div>
}
Which works as it shows the menu, but it also fails, as it destroys the wrap itself.
How can I solve this?
I finally solved it using prepend, append and a blank wrap:
tt_content.gridelements_pi1.20.10.setup {
1 < lib.gridelements.defaultGridSetup
1 {
columns {
10 < .default
10.wrap = <div class="class1">|</div>
}
wrap = |
prepend = COA
prepend {
10 = TEXT
10.value = <div class="class3"><div class="class2">
20 < temp.menu
}
append = COA
append {
10 = TEXT
10.value = </div></div>
}
}
}