Subpage Links with image and text - typo3

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" />
}
}

Related

HMENU/GMENU render pages.media field

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.

typo3 different title in second menu

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

TYPO3 TypoScript: Display a list of subpages with content on parent page

I am trying to create an archive page that displays a list of subpages, similar to WordPress but display the parent's subpages instead of posts. I want the archive page to include the following from the subpage:
Title
First image
First 150 words of regular text element
At the moment I can display a page title, but that's where I got stuck. I am placing the code in a sub template. Here is the code.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
pidInList = this
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.wrap = <div class="project">|</div><hr />
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
10.typolink.parameter.field = uid
}
}
If it helps, all of the images are within the fileadmin/user_upload/ directory, and this is my page structure:
Root
Home
About
Project Portfolio
Project 1
Project 2
Blog
Contact Us
Seems like I figured it out myself, all I had to do was call for content in a separate query. For those that are looking to achieve something similar, here is the code I used to help you out.
lib.portfoliolist = CONTENT
lib.portfoliolist.table = pages
lib.portfoliolist.select {
orderBy = sorting ASC
}
lib.portfoliolist.renderObj = COA
lib.portfoliolist.renderObj {
stdWrap.allWrap = <div class="row">|</div>
stdWrap.wrap = <div class="project col-lg-6 col-md-6 col-sm-12 col-xs-12">|</div>
10 = TEXT
10 {
field = title
wrap = <h2>|</h2>
typolink.parameter.field = pages.uid
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.field = uid
selectFields = header, bodytext
orderBy = sorting ASC
}
renderObj = COA
renderObj {
30 = TEXT
30.value {
field = bodytext
wrap = <div>|</div>
}
}
}
}

Typoscript menu jump to subpage

I want to create a menu with submenu, that's quiet straight forward via typoscript. The challenge is, that I want the parent levels to link directly to the first subpage if the content of the containing page is empty.
I know you can achieve that via shortcut links in the backend, but I want to, if possible, achieve that via typoscript.
Any ideas? I enclode the typoscript menu code I currently use.
lib.mainMenu = COA
lib.mainMenu{
10 = HMENU
10{
# Level 1, further levels are generic
1 = TMENU
1.noBlur = 1
1.expAll = 0
1.wrap = <ul data-role="listview" data-inset="true">|</ul>
1.NO = 1
1.NO.ATagBeforeWrap = 1
1.NO.insertData = 1
1.NO.wrapItemAndSub.insertData = 1
1.NO.wrapItemAndSub = <li id="menu_{field:uid}">|</li>
1.NO.ATagTitle.field = subtitle // title
1.ACT = 1
1.ACT.ATagBeforeWrap = 1
1.ACT.wrapItemAndSub.insertData = 1
1.ACT.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li>
1.ACT.ATagTitle.field = subtitle // title
1.CUR = 1
1.CUR.ATagBeforeWrap = 1
1.CUR.wrapItemAndSub.insertData = 1
1.CUR.wrapItemAndSub = <li id="menu_{field:uid}" class="active">|</li>
1.CUR.ATagTitle.field = subtitle // title
}
20 < .10
20.entryLevel = 1
20.1.wrap = <ul data-role="listview" data-inset="true">|</ul>
30 < .20
30.entryLevel = 2
40 < .20
40.entryLevel = 3
}
Maybe you can build your solution based on hints from here:
http://typo3-blog.net/tutorials/news/if-funktionen-in-typo3.html
In the example from the link above, it's not a menu, but there's a subquery on a table (in your case tt_content) which will then be used to define if something's output or not:
temp.main = COA
temp.main.20 = COA
temp.main.20 {
[...]
wrap=<div class="meine-adressen">|</div>
stdWrap.if.isTrue.cObject = CONTENT
stdWrap.if.isTrue.cObject{
table = tt_address
select {
[...]
}
renderObj = TEXT
renderObj.value = 1
}
}
temp.main.21 = TEXT
temp.main.21 {
wrap=<div class="keine-adressen">|</div>
value = Keine Adressen gefunden
stdWrap.if.isFalse.cObject < temp.main.20.stdWrap.if.isTrue.cObject
}
But I'm not sure if this wouldn't give you headaches in a HMENU
I think it is possible using typoscript, but I dont know how to do it.
The below typoscript may help you:
Typoscript to find the number of content elements in a page:
lib.emptypage = CONTENT
lib.emptypage{
table = tt_content
select{
selectFields = count(uid) AS count
pid = id
}
renderObj = COA
renderObj {
10 = TEXT
10 {
value = {field:count}
insertData = 1
}
}
wrap = |
}
If count is equal to zero, then the page is empty.
Typoscript to get the first subpage:
lib.firstsubpage= HMENU
lib.firstsubpage {
maxItems = 1
1 = TMENU
1 {
NO = 1
}
}
Please share your typoscript solution after implementing it.

HMENU with graphics

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.