Typoscript Breadcrumb - special.range parameter - typo3

I'm struggling with a simple Breadcrumb Navigation in Typoscript. I just want a simple link to the higher-level page. So if you're on page-3 there should be a link to page-2, if on page-4 there should be a link to page-4 and so on.
I've already been testing different special.range parameters. None of them worked for me.

From docs:
If the value is < 0, entryLevel is chosen from "behind" in the rootLine. Thus "-1" is a menu with items from the outermost level, "-2" is the level before the outermost...
In rootline menu that means the -1 level is current page, -2 one level above current, etc. so linking only parent level is as simple as:
lib.linkOneLevelAbove = HMENU
lib.linkOneLevelAbove {
special = rootline
special.range = -2|-2
1 = TMENU
1.NO = 1
}
page.1 < lib.linkOneLevelAbove

Related

How to use Typoscript conditions for page uid?

How do I use conditions to put different headerdata on the home page and 3 other pages using typoscript?
I have tried this:
page {
[treeLevel = 0]
headerData.20.value = Home Page
[END]
[page|uid = 1]
headerData.20.value = Page 1
[END]
[page|uid = 2]
headerData.20.value = Page 2
[END]
[page|uid = 3]
headerData.20.value = Page 3
[END]
}
But the home page outputs Page 3
I have also tried [globalVar = TSFE:id = X] with the same result.
And the object Browser says [ is an invalid character?
According to documentation (thanks to #BerndWilkeπφ for reminding), TypoScript conditions must be placed on top level of your TS (outside of any other structures).
Not in any cObject like page, neither within other conditions.
I realised the problem is because I nested the conditions inside page.
After taking them out it all works fine.

TYPO3 Produce images in different sizes

I have this implementation, using it in a page level 2 submenu. Each level 2 menu has multiple subpages. Each subpage has one image. So this implementation produces an image from each page for each submenu. For example, a submenu with 2 subpages will have 2 images (one from each subpage).
1 = FILES
1 {
references {
table = pages
fieldName = media
data = levelmedia:-1, slide
}
begin = 0
maxItems = 2
renderObj = COA
renderObj {
2 = IMAGE
2 {
file {
//params = -sharpen 50 +profile "*" -quality 100
import.data = file:current:uid
treatIdAsReference = 1
width.optionSplit = 300c|*|400c
height.optionSplit = 350c|*|450c
}
}
}
}
Would like to have images cropped in different sizes such that image 1 is cut to different dimensions from image 2 and so on.
My ImageMagick installation works perfectly. Am actually cropping single images with it without a hitch.
Without the optionSplit above, the images are cut to size nicely. Unfortunately with the optionSplit it simply outputs the images in their original sizes.
How can I produce different image sizes? My understanding is that optionSplit is the way to go (from the manuals). I read in articles that soureCollection for responsive images use optionSplit. I imagine another way would be to use an image register counter and use CASE to determine how to cut image 1, 2, 3 and so on, but am not familiar with register counters (maybe someone can show me how to do this?). And yet another way would be to use a file/image index number but I've tried looking at the manuals for hours for such a pointer and nowhere is it listed if there's any to help with processing. Anybody know a way to do this?
rendering two consecutive images with different paramters will be difficult in typoscript:
your optionsplit can not success as in the renderObj you always have only one file. A bad habit of all renderObj.
on the other hand: there is no property optionSplit. the functionality is build in any wrap property.
therefore a handling in typoscript could be to concatenate the elements, then split them again, but then use different options in the split renderObj to handle it separately.
or implement a counter with a register variable, then evaluate the register to set different values.
easier would be a handling in fluid, where you could use an iterator with the f:forviewhelper, and then do an f:if (for two cases) or an f:switch (for more cases) on {iterator.index} to render individual versions.
Based on #Bernd answer on the fact that each page (as item) is delivered as an object in TMENUs in each iteration, it is possible to achieve such image rendering in one of two ways:
First,
Through the use of two register entries register:count_menuItems which holds the total number of items you will be processing; and register:count_MENUOBJ which holds the index of the current item being iterated (starts at 1). These two can be use in conjunction with a CASE statement to thoroughly process each image to one's liking. If a page has multiple images, there are two more register items one can use, these are, register:FILES_COUNT (which starts to count starting with 0) and register:FILES_NUM_CURRENT. No need for implementing a registry counter since these registry entries are in-themselves, counters.
Secondly,
There's a much easier way, a far less time-consuming way, that uses a wrap as explained by #Bernd, as follows;
NO = 1
NO {
1 = LOAD_REGISTER
1 {
width.cObject = TEXT
width.cObject.stdWrap.wrap = 100c||200c
height.cObject = TEXT
height.cObject.stdWrap.wrap = 300c||400c
}
2 = FILES
2 {
# Get the images related to the current page
references {
table = pages
fieldName = media
}
# Render each image and wrap it as appropriate
renderObj = IMG_RESOURCE
renderObj {
file {
treatIdAsReference = 1
import.data = file:current:uid
width = {REGISTER:width}
width.insertData = 1
height = {REGISTER:height}
height.insertData = 1
}
}
stdWrap {
wrap = <img src="|" />
}
}
}
As you can see, this code is being used in a TMENU and processes each image based on different rules defined in segment 1 and stored by the LOAD_REGISTER. The trick is in the wraps. stdWrap's wrap already contains optionSplit. So by storing the desired pattern, the stdWrap will process the correct value to be stored for each iteration.
It has worked for me. Hope it helps someone.

use typoscript variable in condition

Is it possible to use variables defined in TypoScript in TypoScript conditions?
For example if I define a variable like this:
my_var = 10
Can I create a condition in typoscript that checks if my_var equals 10?
I imagine something like this:
my_var = 10
[my_var = 10]
# do something
[else]
# do something else
[end]
The reason why I need this is the lack of nested conditions. If what I'm asking for is possible, I can do something like this to overcome this limitation:
[globalVar=TSFE:id=1]
# render special layout for page 1
[else]
normal_layout = 1
[end]
[normal_layout = 1] && [globalVar=TSFE:page|layout=1]
# render normal layout 1
[end]
[normal_layout = 1] && [globalVar=TSFE:page|layout=2]
# render normal layout 2
[end]
Another usecase would be to check for the existence of a variable, for example if page was already defined. Example:
[globalVar=TSFE:id=1]
page = PAGE
page.10 = TEXT
page.10.value = hello page 1!
[end]
[!page]
page = PAGE
page.10 = TEXT
page.10.value = hello world!
[end]
I'm surprised that the docs don't answer this already :S
edit
I've tried Andreas Ottos solution, but it still does not seem to work. Here's my example code:
lib.content = TEXT
lib.content.value = this text should not get displayed
[globalVar=TSFE:id=1]
lib.content = TEXT
lib.content.value = this is page 1
[else]
normal_layout = 1
[end]
[globalVar = LIT:1 = {$normal_layout}]
lib.content = TEXT
lib.content.value = this is any other page
[end]
page = PAGE
page.10 < lib.content
In theory, this should render 'this is page 1' for page 1 and 'this is any other page' for any other page. But while page 1 gets rendered correctly, this is not the case for the other pages. They get rendered with 'this text should not get displayed'.
Any ideas? I'm using version 7.6. Is that maybe the problem?
EDIT: For the first UseCase:
It is possible with a TypoScript "literal". See a small hint in the doc here.
And you have to separate the constants from the logic.
So in the constants you have to write:
[globalVar=TSFE:id=1]
normal_layout = 0
[else]
normal_layout = 1
[end]
And in the setups part you can use this variable:
[globalVar = LIT:0 = {$normal_layout}]
# render special layout for page 1
[end]
[globalVar = LIT:1 = {$normal_layout}] && [globalVar=TSFE:page|layout=1]
# render normal layout 1
[end]
[globalVar = LIT:1 = {$normal_layout}] && [globalVar=TSFE:page|layout=2]
# render normal layout 2
[end]
Your second usecase is not really clear but I would recommend to use a base definition of page which is overwritten in the specific cases.

change the form target in powermail 1.6.x with typoscript for a specific form

I have two forms on my page.
I want to change the target of a form with typoscript. The result should be two different "Thank You for contacting me" pages for two different forms on one site.
I've tried the following Typoscript
[globalVar = GP:tx_powermail_pi1|uid55 = 1]
plugin.tx_powermail_pi1.formaction.typolink.parameter = 299
[else]
plugin.tx_powermail_pi1.formaction.typolink.parameter = 258
[end]
In this case I've made a hidden field with the UID 55 and the value 1.
and the second try:
[globalVar = GP:tx_powermail_pi1|mailID < 1613]
plugin.tx_powermail_pi1.formaction.typolink.parameter = 299
[else]
plugin.tx_powermail_pi1.formaction.typolink.parameter = 258
[end]
In this case I simply check the mailID of the posted form (ID 1612 is form number 1 and ID 1618 is form number 2).
but it does not work. In both cases the target is the page with the id 258.
I've also tried the same with globalString.
Typo3 4.6.7 with powermail 1.6.10
If you just want different "Thank you" pages for both forms, then use "Auto-redirect after confirmation-page", which can be found in the plugin-settings (tab "Answer page") of your Powermail forms.

How to display content preview in Typo3

How would one go about displaying the page content as a list of previews pointing to individual content elements, instead of just displaying them all at once? I will be grateful even for just a conceptual answer.
For creating a menu of content elements you can use the content type menu, set the menu type to section index and select a page.
You can of course modify the output by manipulating the TypoScript.
Here an example that adds parts of the bodytext field and an image. The latter is not tested and written in pseudo TypoScript ;-)
tmp < tt_content.menu.20.3.renderObj
page.5 < tt_content.menu.20.3
page.5.renderObj >
page.5.renderObj = COA
page.5.renderObj {
wrap < tmp.wrap
stdWrap.typolink < tmp.typolink
10 < tmp
10.wrap >
10.typolink >
20 = TEXT
20.field = bodytext
20.parseFunc < lib.parseFunc_RTE
20.cropHTML = 100
30 = IMAGE
30.file.import.field = image
30....
}