I have the following page structure:
toppage
-page1
-page2
-page3
-page4
- (menu separator)
-page5
-page6
-page7
-page8
Page1 to page4 are being used to define a horizontal main menu.
Page5 to page7 are being used to define a vertical side menu.
The following typoscript is being used for the main menu:
lib.mainMenu = HMENU
lib.mainMenu.special = directory
lib.mainMenu.special.value = {$main_menu_start_id}
lib.mainMenu.entryLevel = 0
lib.mainMenu.1 = TMENU
lib.mainMenu.1 {
// Fix to limit items in main menu
maxItems = 4
}
Is it possible in typoscript to replace the maxItems approach by something like the following?
Get the pageid of the menu separator.
Using a statement to say that mainMenu should end at this pageid.
Risky approach, I doubt if it will be possible to do that with pure TypoScript
Instead I'd suggest to build horizontal menu (pages 1-4) with special=list example:
lib.mainMenu = HMENU
lib.mainMenu.special = list
lib.mainMenu.special.value = 1,2,3,4
lib.mainMenu.1 = TMENU
//etc
and then vertical menu as a menu of all other items except of the previous 4
lib.sideMenu = HMENU
lib.sideMenu.excludeUidList = 1,2,3,4
lib.sideMenu.1 = TMENU
// etc
other way
you can also put the page which is hidden in menu at the begining let's call it horizontal menu items and then use special=directory in HMENU to build menu with all sub-items. It's also easier add/delete/change items without changing the TS:
structure:
- horizontal menu items (uid: 123, hidden in menu)
|-- page 1
|-- page 2
|-- page 3
--- page 4
- page 5
- page 6
- page 7
TS:
lib.mainMenu = HMENU
lib.mainMenu.special = directory
lib.mainMenu.special.value = 123
lib.mainMenu.1 = TMENU
//etc
lib.sideMenu = HMENU
lib.sideMenu.1 = TMENU
// etc
It is possible. But you cannot use optionSplit then.
(untested)
lib.mainMenu.1.NO.allStdWrap {
prepend = LOAD_REGISTER
prepend {
data = REGISTER:hideMenuItem
ifEmpty = 0
override = 1
override.if.equals.field = doktype
override.if.value = 199
}
if.isFalse.data = REGISTER:hideMenuItem
}
I did not tested, but the main princple should become clear: create an internal REGISTER which is checked for each menuitem. If there is an menu-item of doktype menu-separator (199) then set the register. If the register is set, do not render the menu.
Related
I have a little problem with my navigation and couldn't get it work...I got on every page a breadcrumb navigation which shows the page tree until the current page.
So far so good but when I go to the details page of my news I got the following tree Home > Newest > Article. I don't want to have the page title Article here because every other news would have this tree. Instead of the pagetitle I want to have the news title so I modified my navigation like this:
30 = HMENU
30 {
special = rootline
special.range = 0 | -1
1 = TMENU
1 {
stdWrap.dataWrap = <p>{ date : d.m.Y } ::: |
NO = 1
NO {
wrapItemAndSub = | >
stdWrap.htmlSpecialChars = 1
}
CUR = 1
CUR.allWrap = | </p>
stdWrap.append = RECORDS
stdWrap.append {
if.isTrue.data = GP:tx_news_pi1|news
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
}
}
}
And now the problem: when I click go on a page which is hidden in menus the breadcrumb looks like this Home >. Obviously the last page isn't displayed and this should be solved but I don't know how to do it.
At least I tried something with this in some combinations but cant't get it work
if {
value = 46
equals.field = uid
excludeUidList = 46 //includeNotInMenu = 1
}
When adding includeNotInMenu = 1 under the special.range hidden pages are shown in the breadcrumb title but then the breadcrum in news looks like this Home > Newest > Article NewsTitle and I don't want to have this 'Article' in it. Hope someone of you can help me!
first:
not displaying the current page is ok only for the news-detail page. so use a condition to realize it:
[page|uid = 123]
30.30.special.range = 1|-2
[global]
second:
add the current news title after the menu. the handling is a littel bit easier.
30.40 = RECORDS
30.40 {
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
}
therefore you might need to change the wrap. either split it or (better) give it an additional COA level.
and so the news title only is neccessary on your detail page you put that code into the condition.
Alternatives:
you can use .stdWrap.if to modify the range of the breadcrumb and the display of the news title, but with the TS-condition you have a smaller typoscript for normal pages (faster rendering).
You even need no condition for the tx_news_pi1|news parameter, as the detail page normaly would not show anything (except an error)
For example (since Ext news 7.2) to hide News Detail page in the breadcrumb..
Home > News > News Detail > Article name
page.10.dataProcessing {
100 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
100 {
special = rootline
special.range = 0|-1
includeNotInMenu = 1
as = breadcrumb
}
110 = GeorgRinger\News\DataProcessing\AddNewsToMenuProcessor
110.menus = breadcrumb
}
[page["uid"] == {$pages.newsDetail}]
page.10.dataProcessing.100.special.range = 0|-2
[END]
Results in
Home > News > Article name
i have to build an page with two menus. And in the second menu, i need different titles.
I had the idea to use the alternativ navigation-title. Is it possible to enable this in the first menu and disable in the second?
Thanks!
Yes you can do that by overwriting the stdWrap.cObject:
lib.menu1 = HMENU
lib.menu1.1 = TMENU
lib.menu1.1.NO = 1
lib.menu2 = HMENU
lib.menu2.1 = TMENU
lib.menu2.1.NO = 1
lib.menu2.1.NO.stdWrap.cObject = COA
lib.menu2.1.NO.stdWrap.cObject.10 = TEXT
lib.menu2.1.NO.stdWrap.cObject.10.field = nav_title // title
# = use nav_title field if available or title field as fallback
# also other fields are possible, e.g. subtitle
For your first menu set
NO.stdWrap.cObject = COA
NO.stdWrap.cObject {
10 = TEXT
10.field = title
and in your second menu
NO.stdWrap.cObject = COA
NO.stdWrap.cObject {
10 = TEXT
10.field = subtitle
Tearing my hair out over a TypoScript menu. I need the following behaviour:
A list of "special" menu items pageIDs is maintained in constant {$SPECIAL}
A HMENU is rendered showing the navigation of the site root. If the pageID is "special", then it gets a special div wrap, and a list of its child pages is nested inside of the div wrap. If the item is NOT "special", then it gets no special wrap, and no child pages are shown. All "special" items are shown at the top of the page list.
I've tried a couple of approaches:
Approach 1. Render two HMENUs, one after the other. First menu shows only {$SPECIAL}, second menu shows the siteroot, excluding the {$SPECIAL} items.
Problem: if I use special.directory to show {$SPECIAL}, the parent pages are not rendered. If I use special.list, the child pages are not rendered. Argh!
Approach 2. Render a big chunk of custom menu TS, using if conditions to check if the page is {$SPECIAL}
Problem: I can get the special wraps to show on {$SPECIAL} items, but I can't work out how to then render a list of the child pages specific to each item.
My code for Approach 2 is, so far:
MAIN_NAV.20 = HMENU
MAIN_NAV.20 {
special = directory
special.value = {$SITE_ROOT}
excludeUidList = {$RESTRICTED_ROOT}, {$HOME_SHORTCUT}
1 = TMENU
1{
NO{
# suppress standard menu output
doNotShowLink = 1
# build each menu item conditionally
stdWrap2.cObject = COA
stdWrap2.cObject{
#Standard
10 = TEXT
10{
# not in list of special pages?
if.value = {$NAV_CONTAINERS}
if.isInList.field = uid
if.negate = 1
field = nav_title//title
typolink.parameter.field = uid
wrap = <ul><li>|</li></ul>
}
#Special
20 = TEXT
20.wrap = <div class="SPECIAL"><ul><li><span>|</span>
20 {
if.value.field = uid
if.equals = {$SPECIAL}
field = nav_title//title
}
30 = TEXT
30.wrap = |</li></ul></div>
30 {
if.value.field = uid
if.equals = {$SPECIAL}
}
}
}
}
}
I can't hardcode this (like "Special item 1 as a text element, then Special item 1 children as a menu, then Special item 1 as a text element, then Special item 2 children...") because {$SPECIAL} could theoretically wind up being any number of pages.
Can anyone offer any suggestions to assist with one or other approach?
I think user Ila is right, if you use special = list, you should be able to add multiple levels (child pages) by adding TMENUs.
On the other hand, I've got a similar menu I'd like to share. It contains two kinds of special rendering cases - one with override.if and the other one with CASE.
temp.mainnav = HMENU
temp.mainnav {
wrap = <nav>|</nav>
entryLevel = 0
1 = TMENU
1 {
noBlur = 1
expAll = 1
wrap = <ul>|</ul>
NO {
wrapItemAndSub=<li class="p{page:uid}">|</li>
wrapItemAndSub.insertData = 1
}
}
2 = TMENU
2 {
noBlur = 1
expAll = 1
NO {
wrapItemAndSub=<li>|</li>
// http://labor.99grad.de/2013/07/10/typo3-hmenu-einen-menupunkt-anders-darstellen/
doNotLinkIt.override = 1
doNotLinkIt.override.if {
value = {$pidsDoNotLinkInMenu}
isInList.field = uid
}
stdWrap.wrap.override = <p class="unlinkedMenuItem">|</p>
stdWrap.wrap.override.if {
value = {$pidsDoNotLinkInMenu}
isInList.field = uid
}
}
}
3 = TMENU
3 {
noBlur = 1
expAll = 1
wrap = <ul class="level3">|</ul>
NO.wrapItemAndSub.cObject = CASE
NO.wrapItemAndSub.cObject {
//http://stackoverflow.com/questions/18899573/how-to-apply-a-different-wrap-in-a-tmenu-for-certain-items-only/18910302?noredirect=1#18910302
key.field = uid
// normal item
default = TEXT
default.value = <li class="level3">|</li>
// special item
{$somePid} = TEXT
{$somePid}.value = <li class="level3 foo">|</li>
{$somePid}.append < temp.sometemp
// some other special item
{$someOtherpid} = TEXT
{$someOtherpid}.value = <li class="level3 bar">|</li>
{$someOtherpid}.append < temp.someothertemp
}
}
}
I think both approaches could be used to achieve your goal.
I try to implement a page which contains images to certain subpages. For each subpage, I have a seperate image. I want to display for each subpage the appropriate image "galerie_XX.png" an show the name of the subpage above the image. So far I got:
galerielabel = HMENU
galerielabel.special = directory
galerielabel{
1 = TMENU
1.NO.stdWrap{
wrap = <img src="fileadmin/templates/images/galerie/galerie_|.png" />
}
}
The Subpages are year names, like 2012, 2013... This script shows me the required images as a link.
My question is, how can I add the name of the subpages above the image?
Thank you in advance.
I suggest a different approach.
You can add images in the page properties.
Then, your menu could be like this:
lib.menu = COA
lib.menu.10 = HMENU
lib.menu.10 {
10 = HMENU
10.1 = TMENU
10.1.NO.doNotShowLink = 1 #will remove the link altogether
10.1.NO.before.cObject = COA
10.1.NO.before.cObject {
10 = TEXT
10.field = title #title of the page, change to any field you like
20 = IMAGE
20.file.import = uploads/media/ #4.x style
20.file.import.field = media
20.file.import.listNum = 0 #use first image referenced
20.width = 200 #set to imagesize of your liking
30 = TEXT
30.value = Do what you like here
}
}
Untested: the title of the page should be prepended
galerielabel = HMENU
galerielabel.special = directory
galerielabel{
1 = TMENU
1.NO.stdWrap{
# Prepend with page.title
prepend = TEXT
prepend {
field = title
htmlSpecialChars = 1
}
wrap = <img src="fileadmin/templates/images/galerie/galerie_|.png" />
}
}
In a TYPO3 site, I have a list of sibling pages. Each page has some images in the "media" field. Im trying to make a navigation to go to the previos/next sibling. So far I have this:
# Append Sitenavi for projects
[PIDupinRootline = 43]
page.10.marks.MAIN.20 = HMENU
page.10.marks.MAIN.20{
special = browse
special{
items = next|prev
}
1 = TMENU
1{
NO = 1
}
}
[global]
But instead of using the page title, id like to use the first image from the "files" field. How could I do it?
This is the way to get other fields:
page.10.marks.MAIN.20 = HMENU
page.10.marks.MAIN.20 {
special = browse
special {
items = prev | next
}
1 = TMENU
1 {
NO = 1
NO.stdWrap.field = subtitle // title
}
}
Now if your change subtitle // title to image and add NO.stdWrap.wrap = <img src"|" />, then it should work.