hide page & subpages from menu - typo3

I have the following page structure in TYPO3:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
Now I want to have 1/* + 4/* included in the header menu and 4/* + 7/* in the footer menu. Since the header and footer menus are different, I cannot just use the "hide in menu" feature and need to do it in TypoScript instead.
Here's what I have so far:
HEADERMENU = HMENU
HEADERMENU {
1 = TMENU
1.expAll = 1
1.NO = 1
1.NO {
stdWrap.if.value.field = uid
stdWrap.if.equals = 7
stdWrap.if.negate = 1
}
2 < .1
}
FOOTERMENU < HEADERMENU
FOOTERMENU.1.NO.stdWrap.if.equals = 1
The problem with this is, that it still displays the pages 8+9 in the header and 2+3 in the footer, even if it does not display page 1/7 anymore. I know that I could use if.isInList and the provide all subpage IDs, but then I'd have to change the TypoScript everytime I add a new page. If possible, I'd like to dynamically exclude a page and all its subpages.
How can I do that?

As Daniel mentioned in his answer there is a way to display all subpages of the selected pages. special = directory displays however only the subpages. So you could see only 2/3 and 5/6 and 8/9 in your menus.
special = directory
"This will generate a menu of all pages with pid = 35 and pid = 56."
I would suggest the excludeUidList property.
HEADERMENU = HMENU
HEADERMENU {
excludeUidList = 7
1 = TMENU
1.expAll = 1
2 < .1
}
FOOTERMENU < HEADERMENU
FOOTERMENU.excludeUidList = 1
It is working as a WHERE condition in a db SELECT query, so you won't get those pages on the first level and neither will it find their subpages then.

You could go for the special=directory approach to render a Menu of one or more pages and their subpages.
HEADERMENU.special = directory
HEADERMENU.special.value = 1, 4
More information in the documentation.

Related

Typoscript Menu: if "directory" list is empty then use "entrylevel"

I use the Special Menu element "Menu of sub pages of selected pages".
I would like to modify it so that it shows a sitemap of the sub pages of the current page if there are no entry pages defined - otherwise it should work as usually.
I've tried to overwrite the element like this - but I have no idea how to do the condition for changing from directory to entrylevel.
menu.sub < menu.template // A standard TMENU template
menu.sub {
special = directory
special.value.field = pages
#entryLevel= -1 ***USE THIS IF THE special value ABOVE IS EMPTY***
1.expAll = 1
1.wrap = <ul class="subnav">|</ul>
2.expAll = 1
2.wrap = <ul>|</ul>
3 < .2
}
tt_content.menu.20.1 < menu.sub

TYPO3 menu: how to set "entryLevel" dynamic?

I'm trying to create a menu that displays in TYPO3 all subpages and the parent page. My problem is that I find no way to assign entryLevel dynamically.
I'm working with TYPO3 6.1
This is currently my typoscript for the menu.
lib.mainnavi = HMENU
lib.mainnavi {
entryLevel = 1
1 = TMENU
1.wrap = <ul> | </ul>
1 {
noBlur = 1
NO {
subst_elementUid = 1
allWrap = <li id="link{elementUid}" class="first">| |*| <li id="link{elementUid}">| |*| <li id="link{elementUid}" class="last">|
wrapItemAndSub = |</li>
}
ACT = 1
ACT {
subst_elementUid = 1
allWrap = <li id="link{elementUid}" class="first current first_current">| |*| <li id="link{elementUid}" class="current">| |*| <li id="link{elementUid}" class="last current last_current">|
wrapItemAndSub = |</li>
}
}
}
Below is a picture to illustrate what I want.
When I go to "1", I want to see "FAQ", "GTC (EU)" and "GTC (USA)".
When I go to "FAQ", I want to see A-J and "1" as "back".
When I go to "A", I want to see "FAQ" as "back"
I can make the "back" menu with a seccond menu and special = browse. But I can't find a way to set entryLevel dynamically
Entry level can get positive and negative values.
While the positive values are marking absolute level positions counting from the root page.
Root => 0
- Page => 1
- Page => 2
- Current Page => 3
negative values will be relative and counted from the current page back to the root
Root => -4
- Page => -3
-Page => -2
- Current Page => -1
This way you don't have to use conditions for every level, which would just bloat your caching tables.
Root => 0
- Page => 1
- Current Page => 2
Root => -3
- Page => -2
- Current Page => -1
You can adjust the entryLevel setting with a condition below your TS code. Just have a look at the documentation for the treeLevel condition.
Use it like this:
[treeLevel = 2]
lib.mainnavi.entryLevel = 2
[end]
There is a nother solution, that does not use entryLevel at all:
lib.mainnavi = HMENU
lib.mainnavi {
special = directory
special.value.field = uid
...
}
This would create a menu of pages having the UID of the current page as PID, AKA subpages of the current page.
This did the trick for me:
lib.mainnavi = HMENU
lib.mainnavi {
entryLevel = 1
special = directory
special.value.data = leveluid:-1
# your code here ...
}

List of images as subpart in Typo3

At current I'm making a list of images for a banner slider using code as follows:
page.10.marks.topimage = IMAGE
page.10.marks.topimage {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 0
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
wrap = <div id="slides">|
}
page.10.marks.topimage1 = IMAGE
page.10.marks.topimage1 {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
etc...
However, this means, every time the other admins want to add a new slide or remove one from the total count, I have to change this code. Adding the content of the slides is not a problem, they simply upload to user_upload and it pulls 0 to 3 at current. However, they want to be able to upload 5 images and have it show 5 or just 3 and have it show 3 and I need a more dynamic way to implement this. I'm still new to Typo3 (i really don't understand it, php is 10,000X easier!), so if anyone could, please explain to me better than the docs, how subparts work or what my solution might be.
And no I can't just write an extension to do it. Been there and tried that and still can't figure out how to get extensions in without breaking it.
FYI, if you could break it down and help me "like" it, that would be great, because at current, I'd rather they use wordpress or joomla or ANYTHING but this. If you've seen my other questions, then you'll realize, i've had 0 fun working with this cms and mostly because the documentation and/or "help" i've received has been almost completely useless to me. I only mention this so that maybe someone will break this down for me like i break down jquery/php/.net questions for others. It doesn't hurt to be polite and show a nub "step-by-step" instructions!
page.10.marks.topimage = TEXT
page.10.marks.topimage {
# retrieve data
data = levelmedia: -1, "slide"
override.field = media
# we have some filenames in a list, let us split the list
# and create images one by one
# if there are five images selected, the CARRAY "1" will be executed
# five times where current is loaded with only one filename
split {
# the images are separated via ","
token = ,
# you can do funny stuff with options split, f.e. if you want to give first
# and last image a different class... but thats another topic;)
# we just say, render every splitted object via CARRAY "1"
cObjNum = 1
1 {
# just render the single image,
# now there should be one filename in current only
10 = IMAGE
10 {
file.import.wrap = fileadmin/user_upload/|
file.import.current = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
}
}
}

How to setup a browse menu to cycle a page and it's sub pages only in typo3?

I am trying to set up a browse menu to cycle a page and it's sub pages. I have to have it in the format of < 2 > where < is the previous page, 2 is the current page, and > is the next page. To reslove this I decided to put an extension template on the parent page which in which a browse menu points to the first page of the sub page tree:
lib.pagenumber = HMENU
lib.pagenumber{
special = browse
special.items = | next
special.next.uid = 100
special.next.fields.title = 2
1 = TMENU
1{
noBlur = 1
expAll = 0
NO = 1
NO.ATagTitle = 1
NO.before = <div id="currLGMpg" class= "currpg">1</div>
NO.linkWrap = <div class=nextLGMpg>|</div>
}
}
The current page is not linked but just an image box which has to be between the prev and next links and also be auto numbered. this is the second problem I am trying to solve.
For the subpages I am thinking that a template on the first subpage with option split on the linkwrap would work for styling the prev and next links but I have no idea how to put the image for the current page in the middle.
Hello for cycling you should follows the below steps this only for next please follow same steps for prev.
temp.lightbox_navi.30 = HMENU
temp.lightbox_navi.30 {
stdWrap.wrap = <li>|</li>
special = browse
special {
items = next
items.prevnextToSection = 0
next.fields.title = < next Projekt
}
1 = TMENU
1 {
NO = 1
}
stdWrap.ifEmpty.cObject = HMENU
stdWrap.ifEmpty.cObject {
special = browse
special {
items = first
items.prevnextToSection = 0
first.fields.title = < next Projekt o
}
1 = TMENU
1 {
NO = 1
}
}
}
So I finally solved all but one issue. which is to auto number the page. For those interested, you need to map the next and prev separately to so that you can put a page number button inbetween. The following typoscript code sits on the root page tree of the pages you want to setup browse buttons for:
#Next page button setup
lib.nextpage = HMENU
lib.nextpage.special = browse
lib.nextpage.special.items = next
#can't remove the page title some reason it just gets inserted back so we set it to nothing
lib.nextpage.special.next.fields.title =
#if we're on the parent page of the page tree we wish to browse next should point to the first page of the subtree.
[globalVar = TSFE:id = 46]
lib.nextpage.special.next.uid = 100
[global]
lib.nextpage.1 = TMENU
lib.nextpage.1{
noBlur = 1
expAll = 0
NO = 1
#NO.ATagTitle = 1
NO.linkWrap = <div class=nextLGMpg>|</div>
}
#Page number
lib.currpage = TEXT
#can't autonumber yet so put a 1 as a placeholder for the current page number
lib.currpage.value = 1
lib.currpage.wrap = <div id="currLGMpg">|</div>
#previous page button setup
#copy from next page setup; tbh all we gain is 1 less line code
lib.prevpage < lib.nextpage
lib.prevpage.special.items = prev
lib.prevpage.special.prev.fields.title =
#again if we're at the 1st subpage we need to target the parent page as that is page one.
[globalVar = TSFE:id = 100]
lib.prevpage.special.prev.uid = 46
#next line tests to see if we're at page 1. If we are we remove the prev object because browsing stops here.
[globalVar = TSFE:id = 46]
lib.prevpage >
[global]
lib.prevpage.1 = TMENU
lib.prevpage.1{
noBlur = 1
expAll = 0
NO = 1
#NO.ATagTitle = 1
NO.linkWrap = <div class=prevLGMpg>|</div>
}
Once I figure out how to autonumber I will update the answer.

Typoscript - Splitting "media" and "imagecaption" simultaneously

I have made a plugin where I store many images in the "media" field and jsut as many captions in the field "imagecaption".
Now my wish is to display it like this:
image1.png
caption 1
image2.png
caption 2
image3.png
caption 3
This is how ive been trying to do it, but its not working:
plugin.tx_myplugin_pi1 = COA
plugin.tx_myplugin_pi1{
10 = TEXT
10.field = header
10.wrap = <h1>|</h1>
20 = COA
20{
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
}
}
20 = TEXT
20{
field = imagecaption
split{
token.char = 10
cObjNum = 1
1.current = 1
}
}
}
}
But its not really working, as it shows first all the filenames and then the caption.
How could I do it?
Split is a function which returns all elements. Within 20.10 you get the content of field image, splitted by an newline f.e. and after that, you get the content of 20.20 which has the imagecaption.
What you need to do (untested):
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
# for each image, add the imagecaption
1.append = TEXT
1.append {
field = imagecaption
# split saves the index in REGISTER:SPLIT_COUNT
listNum.stdWrap.data = REGISTER:SPLIT_COUNT
listNum.splitChar = 10
}
}
}
I do not think that token = \n is correct. You properly need to use .char = 10.
Also you will need to nest your TS somehow, because the current solution does handle the fields one by one.
I can't remember at the moment but I've wrote an extension that adds a frame to a picture and caption. It can solve your problem with the captions: http://typo3.org/extensions/repository/view/ch_imgtext_renderengine/current/.