HMENU in TYPO3 Typoscript - menu

I have a project which has multiple websites. Please check the screen shot.
Now, I want to build a menu in "Red", which will contain "Blue", "Post" and "Blog Page" websites. And each tab, that is Blue, Post and Blog Post should display the pages in their websites.
Example:
Red Menu
-Blue
--jQueryTestPage
--Home
--Fluid
--Contact
--Form
-Post
--HomePage
--Contact Us
-Blog Page
--Startsite
--Sitemap
I'm very new to Typo3 and I'm unable to understand how to create menus for these pages. I am using Typo3 6.0.4
Thanks in advance
UPDATE
So far I have the following typoscript code for the menu
lib.mainMenu = HMENU
lib.mainMenu.entryLevel=0
lib.mainMenu.special=list
lib.mainMenu.special.value=19,5,2
lib.mainMenu.1 = TMENU
lib.mainMenu.1 {
wrap = <ul id="mainMenu">|</ul>
expAll = 0
NO.allWrap = <li class="mainMenuiItem">|</li>
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.allWrap = <li class="mainMenuItemActive">|</li>
ACT < .CUR
}
The above code gives me
Red Menu
-Blue
-Post
-Blog Page
But I want is
Red Menu
-Blue
--jQueryTestPage
--Home
--Fluid
--Contact
--Form
-Post
--HomePage
--Contact Us
-Blog Page
--Startsite
--Sitemap

lib.mainMenu.1 means first level. So add additional levels:
lib.mainMenu.2 < lib.mainMenu.1
lib.mainMenu.3 < lib.mainMenu.1
But afaik you need to use "directory" instead of "list". "list" just renders the pages and not the subpages.
And remove entryLevel=0 - if you use special, you should not use entryLevel.
lib.mainMenu = HMENU
lib.mainMenu {
special=directory
special.value=19,5,2
1 = TMENU
1 {
wrap = <ul id="mainMenu">|</ul>
expAll = 0
NO.allWrap = <li class="mainMenuiItem">|</li>
# afaik you do not need RO
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.allWrap = <li class="mainMenuItemActive">|</li>
ACT < .CUR
}
2 < .1
2 {
wrap = <ul>|</ul>
NO.allWrap = ...
CUR.allWrap = ...
}
3 < .2
}

As you're hardcoding the values anyway, you can use special=directory and put in the parent page items manually.
lib.completeMenu = COA
lib.completeMenu {
10 = TEXT
...
# Make Typolink to page 19
}
20 = HMENU
20 {
special=directory
special.value=19
...
# Your menu, just for the first part
}
30 < .10
30.value = ...
# The next typolink to page 5
40 < .20
40.special.value = 5
...
# your menu, for the second part
# repeat this for all the desired steps
}
To avoid writing the same ID multiple times, you can use constants like {$blueRootPage}
PS: above TS is untested

Related

TMENU in Typo3 - insert url from level above

I have a TMENU, and in that menu I would like to insert an URL from "Level 1" into a wrap item in "Level 2".
Current TypoScript looks like this:
10 = HMENU
10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.wrap = <ul><li></li>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
Any hints? Thanks for helping!
stdWrap properties are executed in a defined order (as they appear in documentation), see https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Stdwrap.html#prepend
Knowing that prepend is executed before wrap3 allows to solve this challenge.
page = PAGE
page.10 = HMENU
page.10 {
1 = TMENU
1 {
expAll = 1
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
2 = TMENU
2 {
expAll = 1
stdWrap.prepend = TEXT
stdWrap.prepend {
# remove `value` if page title shall be used
value = URL from Level 1
# using <current-page>.pid value pointing to previous level
typolink.parameter.field = pid
wrap = <li>|</li>
}
# `wrap3` is executed after `prepend`
stdWrap.wrap3 = <ul>|</ul>
NO = 1
NO.allWrap = <li>|</li>
NO.allWrap.insertData = 1
NO.ATagTitle.field = abstract // description // title
}
}
On a page-tree like this
+- A
| +- AA
| +- AB
|
+- B
+- BA
+- BB
The rendered HTML result looks like this
<li>A</li>
<ul>
<li>URL from Level 1</li>
<li>AA</li>
<li>AB</li>
</ul>
<li>B</li>
<ul>
<li>URL from Level 1</li>
<li>BA</li>
<li>BB</li>
</ul>
Update on custom rendering replacing static value property
Instead of using property stdWrap.prepend.value (like shown in example above), other cObject instructions could be used as well - in this case for instance RECORDS (see https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/ContentObjects/Records/Index.html)
The following example renders fields nav_title (and if that's not defined title as fallback) of the parent page.
page.10 {
# ...
2 {
# ...
stdWrap.prepend {
# using `cObject` instead of `value`
cObject = RECORDS
cObject {
tables = pages
source.field = pid
# rendering definition for retrieved record of table pages
conf.pages = TEXT
# `//` is used as fallback delimiter here, NOT as comment
conf.pages.field = nav_title // title
}
# ...

TYPO3 menu with typoscript no code generate

I want to create a menu with Typoscript, but it's doesn't work.
I have no code generate. My <body> is empty.
Here my Typoscript code:
# Default PAGE object:
page = PAGE
page.10 = TEMPLATE
page.10.template = FILE
page.10.template.file = fileadmin/templates/template.html
page.shortcutIcon = fileadmin/templates/favicon.png
page.stylesheet = fileadmin/templates/css/styles.css
page.10.workOnSubpart = DOCUMENT
######################################################
#
# Configuration of SUBPARTS
#
######################################################
# Define the subparts, which are inside the subpart DOCUMENT
page.10.subparts {
##############################################
#
# Subpart NAVMENU
#
##############################################
# The subpart NAVMENU outputs the meta navigation
# at the top right corner of the page
NAVMENU = HMENU
NAVMENU.wrap = <ul>|</ul>
# Only display special pages here: Contact and Imprint
METANAV.special = list
# LIST NEEDS MODIFICATION:
# Take your page IDs!
# Change the values in the following list!
NAVMENU.special.value = 70, 92, 74, 91
NAVMENU.1 = TMENU
NAVMENU.1 {
# NO: default formatting
NO = 0
NO {
# Each entry is wrapped by
# <li> </li>
allWrap = <li>|</li>
}
}
}
######################################################
#
# Configuration of MARKERS
#
######################################################
# Define the markers inside the subpart DOCUMENT
page.10.marks {
}
Here is the tutorial helping me to make my menu: http://wiki.typo3.org/Templating_Tutorial_-_Basics
You have a METANAV in between your NAVMENU configuration:
NAVMENU = HMENU
NAVMENU.wrap = <ul>|</ul>
# Only display special pages here: Contact and Imprint
METANAV.special = list
Change the last line to NAVMENU as well or use curly braces. Make sure in your Template html file a DOCUMENT subpart exsts and inside that subpart a NAVMENU subpart exists. Only then you will see output.
The answer form Daniel is right.
And there are different states of a menu. NO is the default state and you do not need to deactivate it (it's wrong: NO = 0). Only if you need more states you have to set each one like ACT = 1 (CUR = 1 and so on).
NAVMENU= HMENU
NAVMENU {
special = list
special.value = 70, 92, 74, 91
1 = TMENU
1.wrap = <ul>|</ul>
1{
NO{
wrapItemAndSub = <li class="menu-normal">|</li>
}
ACT=1
ACT{
wrapItemAndSub = <li class="menu-active">|</li>
}
}
}

TYPO3 menu based on couple of lists of ids

Is it possible to build menu in TypoScript which is based on couple of list of id's for example:
List one:
20 = HMENU
20.special = list
20.special.value = 35, 56, 51, 43, 22
List two
30 = HMENU
30.special = list
30.special.value = 43, 1, 25, 98
etc..
I need to insert in the footer section a six column menu with different links to different site. Any ideas how to do that in one menu?
What about using directory menu ?
Create a folder in which you put all the pages you want in your menu.
Create a constant with the id of the folder.
Then create a menu like this one:
# Links list
20 = HMENU
20 {
special = directory
special.value = {$constants.page.footer.links}
1 = TMENU
1 {
noBlur = 1
NO {
wrapItemAndSub = <li>|</li>
ATagTitle.field = subtitle // title
}
ACT = 1
ACT {
wrapItemAndSub = <li class="active">|</li>
ATagTitle.field = subtitle // title
}
CUR = 1
CUR {
wrapItemAndSub = <li class="active">|</li>
ATagTitle.field = subtitle // title
}
}
}

rootline not working with TYPO3 4.5 menus

I'm having problems with TYPO3. I have been using it for quite a few years, since version 3.8 but this is my first site using version 4.5 and I am having problems with the menus and the rootline.
I believe it is related to how the rootline is created. using the code below for the breadcrumb/path type of menu only the current page is displayed. The menu only displays page X using example and code below when in page X and it should be
home > section 1 > sb a > page X
home
--- section 1
------- sub A
---------- page X
--- section 2
Also when displaying menus the ACT state isn't being properly activated. As I understand every page in the path/rootline should activate the ACT state and it is not happening with code below.
Has any thing changed in this version?
I have used both piece of codes in many sites up to now in version 4.5
codes
temp.breadcrumbs = HMENU
temp.breadcrumbs.special = rootline
#temp.breadcrumbs.includeNotInMenu = 1
#temp.breadcrumbs.special.range= -2 | -1
temp.breadcrumbs.special.range = 0
temp.breadcrumbs.1= TMENU
temp.breadcrumbs.1.noBlur = 1
temp.breadcrumbs.1.NO.allWrap= | > |*||*| |
## with and without line ... special.range ...
.....
....
temp.topmenu.1 {
wrap = <ul>|</ul>
# NO.allWrap = <li>|</li>
expAll = 1
NO.wrapItemAndSub = <li>|</li>
# Enable active state and set properties:
ACT = 1
ACT.wrapItemAndSub = <li class="current-menu-item">|</li>
}
temp.topmenu.2 = TMENU
temp.topmenu.2.noBlur = 1
temp.topmenu.2 {
wrap = <ul class="sub-menu">|</ul>
NO.linkWrap = <li>|</li>
# Enable active state and set properties:
ACT = 1
ACT.linkWrap = <li class="active">|</li>
#ACT.allWrap = <li class="selected">|</li>
#ACT.ATagBeforeWrap = 1
}
thanks
Ivan.
as cascaval wrote it's quite common to declare begin and end levels, anyway 0 value is aceptable too, as written in doc for entryLevel
Default is "0" which gives us a menu of the very first pages on the site.
Probably you put some TypoScript on the page X which has Rootlevel field checked, so it avoids traversing the tree up-side. I examined your sample code on first implementation I had available and it works as expected.
The range is supposed to be defined as [begin-level] | [end-level] so try:
temp.breadcrumbs.special.range = 0|-1
...or...
temp.breadcrumbs.special.range = 1|-1
-1 means current page.
-2 means the page one level up from the current page.
NOTE: You should probably set temp.breadcrumbs.includeNotInMenu = 1 because usually you would like to have all the pages in the breadcrumbs (as the structure that breadcrumbs represent wouldn't otherwise make sense), that is including those that you don't want to appear in other menus.
Had the same problem in Typo3 6.2.14 and finally found a solution.
After clearing "Template on Next Level" rootline worked perfectly.
Reason:
the root template was referenced in root templates "Template on Next
Level".
Solution:
edit root template
switch to tabfolder "Options"
clear field "Template on Next Level"

Change menu link title into image with typoscript

My typo3 websites has a menu with the follwing typoscript definition:
lib.footernav = HMENU
lib.footernav.special = directory
lib.footernav.special.value = 38
lib.footernav.entryLevel = 0
lib.footernav.1 = TMENU
lib.footernav.1.NO {
ATagParams = class = "footer-link"
}
The menue works just fine. What I want to do is, change the link text into an image, like this:
<a class="footer-link" href="index.php?id=43&L=1">Facebook</a>
to
<a class="footer-link" href="index.php?id=43&L=1"><img src="facebook.gif"/></a>
How can I do that?
If it helps I could also create a new menu for this facebook link.
I recommend to use the "Media" field of the menu's target pages to define, which pages in the menu should be displayed using an image. The Media field can be found in the "Resources" tab of the page properties. It is the perfect solution for your problem because it allows you to freely choose any image for any menu item:
For menu items that you want to appear as an image, use the Media field of the corresponding menu page and select an image to use. For all menu items that you want to appear as text, simply leave the Media field empty.
Here is the TS code to create that behavior:
1 = TMENU
1.NO {
ATagParams = class="footer-link"
# Replace menu item text with image if defined in page tab "Resources"-->"Media"
stdWrap.override.cObject = COA
stdWrap.override.cObject{
10 = IMAGE
10.file.import = uploads/media/
10.file.import.field = media
10.altText.field = title
}
}
UPDATE FOR TYPO3 6.2 WITH FAL:
TYPO3 6.2 includes FAL – a new media resource management system. As the resources tab of the page properties is now also based on FAL, you need a different TypoScript approach to access those image(s). Here is an up-to-date solution:
1 = TMENU
1 {
wrap = <ul>|</ul>
NO = 1
NO {
wrapItemAndSub = <li>|</li>
stdWrap.override.cObject = FILES
stdWrap.override.cObject {
references {
table = pages
fieldName = media
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
titleText.data = file:current:title // field:nav_title // field:title
altText.data = file:current:alternative // field:nav_title // field:title
}
# start with first image
begin = 0
# show only one image
maxItems = 1
}
}
}
The parameter begin defines which of multiple images should be used (e.g. if you need one image as a headline background for the page and another one as an icon in the menus).
If you increase the maxItems parameter, multiple images will be returned (if multiple images are defined in the resources tab).
If you want to append/prepend the image to the menu text instead of replacing it, you have to change stdWrap.override.cObject to after.cObject or before.cObject in the above code.
Another solution is to define a custom class for each link, then change the background image only for according links. This way you can fully control the menu's appearance by css:
lib.footernav.1.NO {
ATagParams = class="footer-link {field:title}"
ATagParams.insertData = 1
}
Results in following html:
<a class="footer-link Facebook" href="index.php?id=43&L=1">Facebook</a>
css:
.Facebook {
background: transparent url(facebook.gif) no-repeat;
text-indent:9999px;
}
EDIT: I recommend the above solution, because it's a quick and fairly clean setup to address a single menu item. However, if you like a clean example from the typoscript textbook:
lib.footernav = COA
lib.footernav.10 = HMENU
lib.footernav.10 {
special = directory
special.value = 38
excludeUidList = 99
1 = TMENU
1.NO {
ATagParams = class = "footer-link"
}
}
lib.footernav.20 = TEXT
lib.footernav.20 {
field = title
typolink.parameter = 99
typolink.ATagParams = class = "footer-link"
}
Assuming that your facebook menu item is page ID 99
Like so lib.footernav.1.NO.stdWrap.wrap = <img src="|.gif" />?
Make sure to add a wrap.htmlSpecialChars = 1 to avoid breaking the HTML code if an editor enters HTML special chars.
lib.footerSocialMedia = HMENU
lib.footerSocialMedia {
special = directory
special.value = 167
1 = TMENU
1 {
wrap = <ul class="social-list right">|</ul>
expAll = 1
noBlur = 1
NO {
wrapItemAndSub = <li class="skew-25">|</li>
doNotLinkIt = 0
stdWrap.htmlSpecialChars = 1
stdWrap.field =
ATagParams =data-title="{field:title}" data-tooltip="true"
ATagParams.insertData=1
stdWrap.wrap = <span class="{field:tx_menuicon_menuicon}"></span>|
stdWrap.wrap.insertData=1
}
ACT = 1
ACT {
wrapItemAndSub = <li class="skew-25">|</li>
doNotLinkIt = 0
stdWrap.field =
stdWrap.htmlSpecialChars = 1
ATagParams =data-title="{field:title}" data-tooltip="true"
ATagParams.insertData=1
stdWrap.wrap = <span class="{field:tx_menuicon_menuicon}"></span>|
stdWrap.wrap.insertData=1
}
}
}
First you need to add image in media of page under Page->edit and then add the image in media. Further, use the following typoscript:
stdWrap.override.cObject = COA
stdWrap.override.cObject{
10 = IMAGE
10.file.import = uploads/media/
10.file.import.field = media
10.altText.field = title
}

Resources