Load register inside TMENU - typo3

In a TYPO3 HMENU, the second level TMENU should reproduce the abstract of the first level page.
I do manage to fill the register with a value and use it in the second level TMENU - but I am unable to load the field's content into the register.
So
field = abstract
as well as
value = {field:abstract}
value.insertData = 1
don't produce any output.
How can that register be filled with the parent page's abstract?
Here's the full code.
temp.main_nav = HMENU
temp.main_nav {
wrap = <nav id="cbp-hrmenu" class="clearfix cbp-hrmenu span12">|</nav>
entryLevel = 0
1 = TMENU
1 {
noBlur = 1
expAll = 1
wrap = <ul class="level1">|</ul>
NO {
wrapItemAndSub=<li>|</li>
before.cObject=LOAD_REGISTER
before.cObject{
parentAbstract.stdWrap.cObject=TEXT
parentAbstract.stdWrap.cObject{
field = abstract
#value = {field:abstract}
#value.insertData = 1
}
}
}
}
2 < .1
2.stdWrap.dataWrap = <div class="cbp-hrsub"><div class="cbp-hrsub-inner"><div>{register:parentAbstract}</div><div><ul class="level2">|</ul></div></div><!-- /cbp-hrsub-inner --></div><!-- /cbp-hrsub -->
}
PS: {levelfield} seems to be problematic inside a TMENU, that's why I switched to LOAD_REGISTER

Solved it.
The problem was in
2 < .1
The second TMENU inherited the load_register from the first one and kept filling it. That's why there was a wrong abstract (e.g. an empty one) in it.
Here's the working code:
temp.main_nav = HMENU
temp.main_nav {
wrap = <nav id="cbp-hrmenu" class="clearfix cbp-hrmenu span12">|</nav>
entryLevel = 0
1 = TMENU
1 {
noBlur = 1
expAll = 1
wrap = <ul class="level1">|</ul>
NO {
wrapItemAndSub=<li>|</li>
before.cObject=LOAD_REGISTER
before.cObject{
parentAbstract.cObject=TEXT
parentAbstract.cObject{
field = abstract
}
}
}
// EDIT: if you have additional states, don't forget to add the abstract too
ACT < .NO
ACT = 1
ACT {
wrapItemAndSub=<li class="dropdown active">|</li>
}
}
2 = TMENU
2 {
noBlur = 1
expAll = 1
stdWrap.dataWrap = <div class="cbp-hrsub"><div class="cbp-hrsub-inner"><div>{register:parentAbstract}</div><div><ul class="level2">|</ul></div></div><!-- /cbp-hrsub-inner --></div><!-- /cbp-hrsub -->
NO {
wrapItemAndSub=<li>|</li>
}
}
}

Related

TYPO3 add section to link in TMENU

I try to build a simple menu where the field "subtitle" (if set) from the page is added as anchor to the link
MAINMENU2 = HMENU
MAINMENU2 {
special = directory
special.value = 1
1 = TMENU
1 {
expAll = 1
wrap = <ul class="menu">|</ul>
noBlur = 1
NO = 1
NO.stdWrap.typolink.section.field = subtitle
}
}
output: Page XY
expected: Page XY
How must the TypoScript look like to get this work?
You need to disable the automatic link building of TMENU with doNotLinkIt and then build the complete link with typolink:
NO {
doNotLinkIt = 1
stdWrap.typolink {
parameter.field = uid
section.field = subtitle
}
}

Typoscript HMENU: get level 1 title in level 2 navigation

I need to create a menu where, for mobile purposes, before all entries of level 2 there is the title of level 1. Example: my structure looks like this:
team
Max
Sepp
projects
project 1
project 2
now I want my navigation to look like this:
<ul>
<li>
<a>Team</a>
<div class="dropdown-menu">
<ul>
<li>Team</li>
<li><a>Max</a></li>
<li><a>Sepp</a></li>
</ul>
</div>
</li>
<li>
<a>Projects</a>
<div class="dropdown-menu">
<ul>
<li>Projects</li>
<li><a>Project 1</a></li>
<li><a>Project 2</a></li>
</ul>
</div>
</li>
</ul>
So I need in level 2 the title of level 1. how to I access field: nav_title for the parent element?
My typoscript looks like this:
temp.nav = HMENU
temp.nav {
1 = TMENU
1 {
expAll = 1
wrap = |
noBlur = 1
stdWrap.innerWrap.cObject = LOAD_REGISTER
stdWrap.innerWrap.cObject {
level1Title.field = nav_title//title
}
NO = 1
NO {
...
}
}
2 = TMENU
2 {
expAll = 1
stdWrap.dataWrap = <ul><li> {register:level1Title}</li>|</ul><a>Jetzt Mitglied werden</a></div>
noBlur = 1
NO = 1
NO {
...
}
}
}
I tried it with LOAD_REGISTER but that doesnt work. Any suggestions?
what you want is the default behaviour of TYPO3 menus. You just need to set the correct wrapping. Do the wrapping where it belongs:
temp.menu = HMENU
temp.menu {
1 = TMENU
1 {
expAll = 1
wrap = <ul>|</ul>
NO = 1
NO {
wrapItemAndSub = <li>|</li>
}
}
// as you have no specific wrapping all levels can be generated the same:
2 < .1
3 < .2
}
if you want specific wraps on each level you can adapt it after copying (in this example you can see where a wrapping is coming from)
temp.menu = HMENU
temp.menu {
1 = TMENU
1 {
wrap = <ul class="level1">|</ul>
NO = 1
NO {
wrapItemAndSub = <li class="lev1">|</li>
}
}
2 < .1
2 {
wrap = <ul class="level2">|</ul>
NO.wrapItemAndSub = <li class="lev2">|</li>
}
3 < .2
3 {
wrap = <ul class="level3">|</ul>
NO.wrapItemAndSub = <li class="lev3">|</li>
}
}
.
EDIT: after clarification of problem:
working with LOADREGISTER in menus would result in a mess as the menu items are not generated inline recursive.
If you want to repeat the menuitem you should generate it in place.
Therefore you need to split the clean wrappings and use soem enhanced menu magic.
temp.menu = HMENU
temp.menu {
1 = TMENU
1 {
wrap = <ul class="level1">|</ul>
NO = 1
NO.wrapItemAndSub = <li>|</li>
// only for menuitems which contains further pages:
IFSUB < .NO
IFSUB {
// beginning the part of the submenu
after.cObject = TEXT
after.cObject {
field = nav_title // title
wrap = <div class="dropdown-menu"><ul><li>|</li>
}
}
}
2 < .1
2 {
// no beginning in wrap needed as it is done at level 1
wrap = |</ul></div>
}
}
further levels need additional handling. e.g.: 2.IFSUB > and 3.wrap = <ul>|</ul>
Note: If you want a clean html with indentions you need to use .noTrimWrap and multi line values in typoscript.

TYPO3 CASE within HMENU based on pid

I am trying to get the second level of my HMENU to be different depending on what the parent id is.
Specifically, I need to add a COA to the TMENU when the pid is a specific number.
I figured I should be able to do this somehow using a CASE, but I haven't found the right setup to get it working right.
This is my incorrect code that shows what I want to do:
lib.mymenu = HMENU
lib.mymenu {
1 = TMENU
1 {
...
}
2 = CASE
2 {
key.field = pid
default = TMENU
default {
stdWrap.wrap = <ul>|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
23 = TMENU
23 {
stdWrap.wrap = <ul>|</ul>
expAll = 1
NO = 1
NO.stdWrap.cObject = COA
NO.stdWrap.cObject {
...
}
}
}
}
I doubt that you have the pid available at that level.
As the main part is identical I would differ only at the stdWrap with a simple if-wrap:
2 = TMENU
2 {
stdWrap.wrap = <ul>|</ul>
expAll = 1
NO = 1
NO {
wrapItemAndSub = <li>|</li>
/// what wrap do you want to use???
stdWrap.wrap {
cObject = COA
cObject {
:
}
if.equals.field = pid
if.value = 23
}
}
in your code you also use cObject on stdWrap which does not match as stdWrap is no active wrap, but a container for a set of (wrap)functions.

TypoScript Menu with manual columns

I have a typical grid-based dropdown menu with predefined columns, as you find them in foundation, bootstrap etc.
Now I'd like to manually let the editor control which items go in which column – without having to hardwire too many pids or creating additional pagetree nodes (Pages like "Group for column 1") in the BE.
How do I do that with TypoScript?
The page type "Spacer" or "Separator" (doktype 199) is perfect for this:
It can be rendered as html content, using the SPC state. Editors can place it in their pagetree where they want to split up columns.
lib.main_nav_1 = HMENU
lib.main_nav_1 {
special = directory
special.value = {$pidEntryPoint}
wrap = <div class="columns small-12 medium-3"><ul>|</ul></div>
1 = TMENU
1 {
expAll = 1
NO {
text = nav_title // title
wrapItemAndSub=<li>|</li>
}
ACT < .NO
ACT {
wrapItemAndSub = <li class="active">|</li>
}
ACT = 1
CUR < .NO
CUR {
wrapItemAndSub = <li class="current">|</li>
}
CUR = 1
SPC = 1
SPC {
doNotLinkIt = 1
doNotShowLink = 1
allWrap = </ul></div><div class="columns small-12 medium-3">|<ul>
}
}
2 < .1
2 {
wrap = <ul>|</ul>
SPC = 0
}
}
}

HMENU only pages with a specific value in custom field

I have a custom field (lets say its named myfield) in the table pages with the values 0, 1 or 2. I now want to create a HMENU for all pages that have a specific value (for example all pages with myfield=1) in this field.
How could I get this?
As far as I know I can not add a where-clause to the HMENU. So will I need a USER_INT for it?
Will it work somehow like this:
includeLibs.something = mypath/user_myclass.php
lib.servicenav = HMENU
lib.servicenav {
special = list
special.value = USER
special.value.userFunc = user_myclass->myFunction
special.value.myfieldvalue = 1 # 0, 1, or 3
}
user_myclass.php->myFunction:
function myFunction($a, $myfieldvalue) {
// - search all pages with $myfieldvalue
// - add all pids of this page to the returnvalue (as string)
$returnvalue = "5, 19, 200";
return $returnvalue;
}
Will this solution work? Are there better solutions?
Edit: cascavals solution:
It works in a small testproject with this:
lib.menu = HMENU
lib.menu{
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
where = myfield=0
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
entrylevel = 1
1 = TMENU
1.NO = 1
1.NO.linkWrap =
<div class="menu">|</div>
überschreibt
2 < .1
2.NO.linkWrap =
<div class="menu-ebene2">|</div>
But it does not work in a bigger project with this (I get no output):
Also when I copy the Menu from above it does not work in this project..
lib.navigation = HMENU
lib.navigation {
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
where = myfield=0
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
1 = TMENU
1 {
noBlur = 1
expAll = 0
wrap = <ul class="nav1">|</ul>
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
altText = subtitle // title
title = subtitle // title
}
CUR < .NO
CUR.ATagParams = class="active"
CUR.wrapItemAndSub = <li class="current first">|</li> |*| <li class="current">|</li> |*| <li class="current last">|</li>
ACT < .CUR
ACT = 1
ACT.ATagParams = class="active"
}
2 = TMENU
2 < .1
2 {
expAll = 0
wrap = <ul class="nav2">|</ul>
}
}
As special.value has stdWrap, you can still select page UIDs dynamically and create a comma-separated list that is expected:
lib.servicenav = HMENU
lib.servicenav {
special = list
special.value.cObject = CONTENT
special.value.cObject {
table = pages
select {
pidInList = [UID of the root page of your website]
recursive = 99
where = myfield=1
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
}