I would appreciate support with the following problem:
in old times (before FLUID) it was possible to extract the value of field subtitle instead of nav_title for a menu with subpages with:
tt_content.menu.20.1.1.NO {
stdWrap.cObject = COA
stdWrap.cObject {
10 = TEXT
10.field = subtitle // nav_title
}
}
How is it possible to get the same result with FLUID?
I have tried:
tt_content.menu_subpages.dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10.titleField = subtitle // nav_title
}
and
tt_content.menu_subpages.dataProcessing.10.titleField = subtitle // nav_title
but it doesn't work out. Output is still default nav_title (although fields subtitle of all subpages have a value)
Thanks for support!
Look into your fluid template. there you have access to the whole pages record.
What you need is something like:
{f:if(condition:page.subtitle, then:page.subtitle, else:page.nav_title)}
or:
{f:if(condition:page.subtitle, then:page.subtitle, else:'{f:if(condition:page.nav_title, then:page.nav_title, else:page.title)}')}
In setup.typoscript (Typo3 9.5.x and 10.4.x)
page{
10 {
dataProcessing.10.titleField = subtitle // title
}
}
The variable path (page.10.dataProcessing) depends on your setup.
Related
I am migrating typoscript from TYPO3 6.2 ELTS to 7.x ELTS.
Following code works in 6.2 thanks to activateContentAdapter which is removed in TYPO3 7. https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/7.2/Breaking-66034-DropContentAdapter.html
Is that possible to still use HMENU/GMENU or should I rewrite it totally other way?
lib.navigation.socialmedia = HMENU
lib.navigation.socialmedia{
wrap = <ul>|</ul>
special = directory
special.value = 123
1 = GMENU
1{
NO{
wrap = <li class="first">|</li>|*|<li class="middle">|</li>|*|<li class="last">|</li>
altImgResource.import = uploads/media/
altImgResource.import.field = media
altImgResource.import.listNum = 0
ATagTitle.field = subtitle // title
}
}
}
you still could use GMENU but you need to change the filehandling. As mentioned files are no longer just copied to uploads/media/ but there is a file-handle (sys_filerecord) whose uid is used everywhere.
First substitution: treatIdAsReference
This is a usage for rendering an icon of the first media entry in a text menu (TMENUITEM) before the text (1).
The rendering is inside of the FILESobject which represents an (possible) array. SO it might be a little bit complicated to insert it into an IMGRESOURCEobject (2).
if you just want the resource adapt the renderObj, as this example renders the image (cropped) and generates an <img>tag.
NO.stdWrap.prepend = FILES
NO.stdWrap.prepend {
references {
table = pages
uid.data = current:originalUid // current:uid
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 150c
height = 150c
}
altText.data = file:current:alternative
titleText.data = file:current:title
params = class="menu-img"
stdWrap.typolink.parameter.field = uid
}
maxItems = 1
}
(1) with the options of CSS3 and HTML5 and the preferred way of accessibility you have multiple ways to use a clean text menu without 'hiding' text in graphics.
(2) you might use altImgResource.cObject = FILES and render an IMGRESOURCE instead of an IMAGE.
meanwhile (since TYPO3 9) you have menu_processors and you would render the menu with fluid, where you 'navigate' through the pagetree with all properties of each page, including images.
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
I am working on TYPO3 6.2 and In a page I have added the content element "Special menu" with the the option Site map with selected page. I was able to render this with out any issues.For almost all pages I have added navigation title and obviously in the site map also this navigation title will be displayed.My requirement is that I want to show title instead of nav_title.Tried the below code and doesn't seems to work . Can any one help me with this?
tt_content.menu.20.2.1 {
NO {
stdWrap.cObject = COA
stdWrap.cObject {
10 = TEXT
10.field = subtitle
}
ATagTitle.field = subtitle
}
}
Any help would be appreciated.
Insert the following lines to the setup field of an ext-template at the page where you want to display the plugin "Special menu" with option "Site map" and wont to change link title to subtitle.
tt_content.menu.20.2 >
tt_content.menu.20.2 = HMENU
tt_content.menu.20.2.1 = TMENU
tt_content.menu.20.2.1 {
expAll = 1
wrap = <ul>|</ul>
NO{
wrapItemAndSub = <li>|</li>
stdWrap.htmlSpecialChars = 1
stdWrap.field = subtitle//title # add title of link subtitle or if empty title
ATagTitle.field = nav_title//title #title add tag title what you need
}
}
tt_content.menu.20.2.2 < tt_content.menu.20.2.1
tt_content.menu.20.2.3 < tt_content.menu.20.2.1
tt_content.menu.20.2.4 < tt_content.menu.20.2.1
Example http://www.typozone.com/index.php?id=96
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.