[TYPO3-english] conditional menu based on menu page-id
Joerg Wagner [DigiLog]
news.netfielders.de at digilog.de
Mon Nov 30 15:32:53 CET 2009
Hi David,
> I would like one item on a menu to display differently according to
> it's page id, ...
here is a "little" something that solves your problem - and goes
somewhat beyond it. You can easily isolate the solution that is adequate
for your problem.
This is a HMENU where the output of some of the child pages is formatted
(very) individually. You will find menu items that come out as icons and
others that come out as search forms to call an indexed-search subpage.
You will also find advanced typolink modification that creates
tip-a-friend menu items.
Hope this helps.
Cheers,
Jörg.
##### TS-CONFIG #####
# The following TS-SETUP expects some vars to be set in TS-CONFIG that
# hold the UIDs of the root page of the HMENU (I always use a sys
# folder page for that) and the UIDs of those pages in the menu that
# should create special output formatting in the menu:
temp.UIDmenuroot = 23
temp.UIDsearch = 24
temp.UIDprintpage = 25
temp.UIDtipfriend = 26
##### TS-SETUP #####
## HEADSUBNAV Form + Print + Mail Buttons [Begin]
lib.headSubNav = HMENU
lib.headSubNav{
special = directory
special.value = {$temp.UIDmenuroot}
1 = TMENU
1{
SPC = 1
SPC {
# spacer creates a simple line break
doNotShowLink = 1
allWrap = <br />
}
NO{
# suppress standard menu output...
doNotShowLink = 1
# ...and build each menu item conditionally
stdWrap2.cObject = COA
stdWrap2.cObject{
# Standard
# for all normal pages that should NOT get special treatment:
recreate normal link
10 = TEXT
10{
# not in list of special pages?
# ATTENTION: Keep this list current with all UIDs that are
treated specially (see below in this COA)
if.value =
{$temp.UIDsearch},{$temp.UIDprintpage},{$temp.UIDtipfriend}
if.isInList.field = uid
if.negate = 1
field = nav_title//title
typolink.parameter.field = uid
}
# Search form
20 = COA
# TS FORM object has not .if attribute - so we have to wrap in
a separate COA
20{
# ATTENTION: Also keep if.isInList in top COA.10 current!!!
(with all specially treated uids)
if.value.field = uid
if.equals = {$temp.UIDsearch}
10 = FORM
10{
dataArray{
5.type = tx_indexedsearch[submit_button]=submit
5.value.field = nav_title//title
10.label = SUCHBEGRIFF
10.type = tx_indexedsearch[sword]=input
10.required = 0
20.type = tx_indexedsearch[_sections]=hidden
20.value = 0
21.type = tx_indexedsearch[_freeIndexUid]=hidden
21.value = _
22.type = tx_indexedsearch[pointer]=hidden
22.value = 0
23.type = tx_indexedsearch[type]=hidden
23.value = 1
24.type = tx_indexedsearch[ext]=hidden
24.value = 0
}
layout = ###FIELD###
type = {$temp.UIDsearch}
REQ = 1
locationData = 1
params.input = class="inputsearch"
params.submit = class="inputsubmit"
goodMess =
badMess ={$styles.content.searchform.badMess}
}
}
# Print (icon)
30 = IMAGE
30{
# ATTENTION: Also keep if.isInList in top COA.10 current!!!
(with all specially treated uids)
if.value.field = uid
if.equals = {$temp.UIDprintpage}
file = fileadmin/templates/img/printpage.gif
alttext.field = nav_title//title
stdWrap.typolink{
parameter = {page:uid}
950x600:left=0,top=0,scrollbars=yes,resizable=yes,location=no,toolbar=yes,menubar=yes
parameter.insertData = 1
addQueryString = 1
addQueryString.method = GET
addQueryString.exclude = id, cHash, no_cache, print
# either no_cache or cHash must be used, otherwise the page
will
# open up from cache and will not use the print template!
#useCacheHash = 1
#no_cache = 1
# # same as &no_cache=1 :
# additionalParams = &print=1&no_cache=1
additionalParams = &print=1
}
#[globalVar = GP:print=1]
# SPECIALS TO SHOW ONLY IN THE PRINTPAGE
#[global]
}
# # Print (plain text)
# 31 = TEXT
# 31{
# # ATTENTION: Also keep if.isInList in top COA.10 current!!!
(with all specially treated uids)
# if.value.field = uid
# if.equals = {$temp.UIDprintpage}
#
# field = nav_title//title
# typolink{
# parameter = {page:uid}
950x600:left=0,top=0,scrollbars=yes,resizable=yes,location=no,toolbar=yes,menubar=yes
# parameter.insertData = 1
# addQueryString = 1
# addQueryString.method = GET
# addQueryString.exclude = id, cHash, no_cache, print
# # either no_cache or cHash must be used, otherwise the page
will
# # open up from cache and will not use the print template!
# #useCacheHash = 1
# #no_cache = 1
# # # same as &no_cache=1 :
# # additionalParams = &print=1&no_cache=1
# additionalParams = &print=1
# }
# }
# Tip-A-Friend (icon)
40 = IMAGE
40{
# ATTENTION: Also keep if.isInList in top COA.10 current!!!
(with all specially treated uids)
if.value.field = uid
if.equals = {$temp.UIDtipfriend}
file = fileadmin/templates/img/tipfriend.gif
alttext.field = nav_title//title
stdWrap.typolink.parameter.cObject < lib.tipurl
}
# # Tip-A-Friend (plain text)
# 41 = TEXT
# 41{
# # ATTENTION: Also keep if.isInList in top COA.10 current!!!
(with all specially treated uids)
# if.value.field = uid
# if.equals = {$temp.UIDtipfriend}
#
# field = nav_title//title
# typolink{
# parameter.field = uid
# additionalParams.cObject < lib.tipurl_param
# }
# }
}
}
}
}
# Create tipUrl parameter incl. current page link (rawUrlEncoded) needed
for URL to "Tip-a-Friend" page
lib.tipurl_param = COA
lib.tipurl_param{
# Prepend with param name
stdWrap.wrap = &tipUrl=|
# Parse query string created below through rawUrlEncoded so that it
can itself be used as a query param
stdWrap.rawUrlEncode = 1
# Add domain (baseURL) to link
10 = TEXT
10.data = TSFE:baseUrl
# Append URL of current page including all parameters from the query
string
20 = TEXT
20.typolink.parameter.data = page:uid
20.typolink.addQueryString = 1
20.typolink.addQueryString.method = GET
20.typolink.addQueryString.exclude = id
20.typolink.returnLast = url
}
lib.tipurl = COA
lib.tipurl{
# Create link to "Tip-a-Friend" page
# PID of ToF page must be defined in TS Constants: temp.UIDtipfriend
10 = TEXT
10.typolink.parameter = {$temp.UIDtipfriend}
10.typolink.returnLast = url
10.typolink.additionalParams.cObject < lib.tipurl_param
}
David Banning schrieb am 01.06.2009 19:39:
> I would like one item on a menu to display differently according to it's
> page id, but I can't seem to find the matching syntax for the menu/page id.
>
> For instance
>
> [globalVar = TSFE:id=799]
> libmenu.1.IFSUB.doNotLinkIt = 1
> [END]
>
> will match when you are -on- page 799, but I want the menu link
> that -points- to page 799 to change, regardless of where you are on the site.
>
>
>
More information about the TYPO3-english
mailing list