HMENU/GMENU render pages.media field - typo3

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.

Related

Typoscript 9.5 render FILES Object like Contentelement

i get via CONTENT an Element from the page and want to render the image from this like all other images in the page.
i have installed sms for responsive images but when i render this image via typoscript an normal <img> will be outputtet.
how must i change my typoscript to render like in the partial file Media/Rendering/Image?
20 = FILES
20{
references {
table = tt_content
fieldName = image
uid.data = field:uid
}
begin = 0
maxItems = 1
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
file.width = 1920c
file.treatIdAsReference = 1
stdWrap.outerWrap = |
}
}
thank you very much!
As the example you mention is rendered in Fluid, I'd suggest to use Fluid as well. The ViewHelper for responsive images is used in Fluid.
Try to get away from rendering via TypoScript and use Fluid templates.

typo3 add image resource as background

I'm totally new to typo3, I need to make a div with background from a specific page. For example on home page, I would like to use a media resource from page id 20.
I got something like that
page.20 = TEMPLATE
page.20.template = FILE
page.20.template.file = fileadmin/refood/layouts/home.html
page.20.workOnSubpart = DOCUMENT
page.20.subparts{
BOX1 < styles.content.get
BOX1.select.where = colPos=1
BOX1.wrap = <div class="offers"><div class="home-box-desc"></div><div class="home-box-desc">|</div><div class="meta-square-green"></div></div>
BOX1.stdWrap.typolink.parameter = 14 _self home-box }
I tried to use something like that
references {
table = pages
uid.data = 20
fieldName = media
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
altText.data = file:current:title
wrap = <div class="offers">|</div>
}
BOX1.wrap = <div class="home-box-desc" style="background:url(|)"></div>
Into a subpart part, but nothing happens. How should I make it ?

Pass content from TypoScript to fluid template in TYPO3 7.6

I would like to read content via TypoScript and render it through a custom Fluid template. Without css_styled_content or fluid_styled_content.
temp.test = CONTENT
temp.test {
table = tt_content
select.languageField = 1
select.selectFields = bodytext,image,header,header_link
select.where = colPos = 1
renderObj = FLUIDTEMPLATE
renderObj {
file = path/to/Teaser.html
}
}
This works with strings, say
<f:debug>{data.header}</f:debug>
But not with
<f:debug>{data.image}</f:debug>
returning only the number of images.
Now, in a classic TypoScript RenderObj (maybe a COA), you would have added something like
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid // file:current:uid
file.width=654
file.height = 327c
//stdWrap.typolink.parameter.data = file:current:link
altText.data = file:current:description // file:current:title // file:current:alternative
}
}
While nowadays, we want to do that in the Fluid template. But how to resolve the FAL image to pass it to the fluid template?
You should be able to use the TYPO3\CMS\Frontend\DataProcessing\FilesProcessor data processor that will fetch the file data for you so you can access it with {files} in your template.
renderObj = FLUIDTEMPLATE
renderObj {
file = path/to/Teaser.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10.references.fieldName = image
}
}
The main problem is all image information are stored in a different table called "sys_file_reference". Selecting "tt_content.image" will not help you here. There are 2 ways to solve this problem, IMHO.
1) Create your own viewhelper. This VH can be utilized to query the images as it is done here.
2) Create a small TypoScript lib and use it as f:cObject in your fluid template. This is described here.
I'm not saying that my solution is the best one. But it's the only one I'm aware of. Looking forward seeing better solutions ;)

Subpage Links with image and text

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

Typo3 resources media files/sys_file_reference for TMENU

How can I use resources media files -> Description (Caption) for altTag/altText in menu.
In TYPO3 you have the possibility to use the page properties for a resource image and to set additional metadata. I found this reference: data [sys_file_reference] [6] [description]
NO = 1
NO {
ATagTitle.field = title
wrapItemAndSub = |</li>
allWrap = <li>|
after.cObject = IMAGE
after.cObject {
file.import.field = media
file.import = uploads/media/
file.import.listNum = 0
file.width = 250c
altText = {???:description}
altText.insertData = 1
}
stdWrap.htmlSpecialChars = 1
}
Since TYPO3 6.0 the media field uses File Abstraction Layer (FAL) to create references to uploaded objects (e.g. images). Because of this change, you can't use the IMAGE content object to fetch the inserted object, but first have to use the FILES content object.
For you case, the TypoScript should look like this:
after.cObject = FILES
after.cObject {
references.data = levelmedia:-1, slide
references.listNum = 0
renderObj = IMAGE
renderObj.altText.data = file:current:description
renderObj.file {
import.data = file:current:publicUrl
width = 250c
}
}
References: http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Files/Index.html