Typoscript image size based on layout - typo3

I want to set the image height among other things based on the layout using typoscript. The setup I have works great for setting an image wrap etc but I can't get the height setting to work...
The documentation seems to suggest that what I have here should work:
temp.image < tt_content.image.20
tt_content.image.20 = CASE
tt_content.image.20 {
key.field = layout
default < temp.image
1 < temp.image
1 {
1.file.width =
1.file.height = 50m
}
}
tt_content.textpic.20 = < tt_content.image.20.default
Anyone know what I have done wrong here?

Instead of 1.file.height = 50m I instead needed to use:
equalH >
equalH = 50m

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 `jh_opengraphprotocol` extension and custom og:image tag

I have a question, does anybody know how to make jh_opengraphprotocol extension show first image from tt_news appear as <meta property="og:image" ...>?
I have tried few things and now I'm stuck at passing a custom image value to that extension.
Getting first image from currently show tt_news (TypoScript Setup):
lib.tt_news_image = CONTENT
lib.tt_news_image {
stdWrap.if.isTrue.data = GP:tx_ttnews|tt_news
table = tt_news
select {
pidInList = 20
recursive = 2
where = CHAR_LENGTH(image) > 0
andWhere.cObject = TEXT
andWhere.cObject {
data = GP:tx_ttnews|tt_news
intval = 1
wrap = uid = |
}
}
renderObj = TEXT
renderObj {
field = image
split {
token = ,
cObjNum = 1
max = 1
1.cObject = IMG_RESOURCE
1.cObject {
file {
import = uploads/pics/
import.current = 1
width = 200m
height = 200m
}
stdWrap.wrap = {TSFE:baseUrl}|
stdWrap.insertData = 1
}
}
}
}
This works fine. When showing this value in FE I get a nice URL to resized file - GREAT!
Now I have hoped to pass that value to the extension and here a have met some problems. Few tries below...
#1 plugin.tx_jhopengraphprotocol.image = lib.tt_news_image
Fail - nothing happens because plugin.tx_jhopengraphprotocol.image is a constant
#2
After some digging I found that plugin is loading a USER object into page.669 like below:
config.htmlTag_setParams := appendString(xmlns:og="http://ogp.me/ns#")
includeLibs.tx_jhopengraphprotocol = EXT:jh_opengraphprotocol/Classes/Service/OgRendererService.php
temp.tx_jhopengraphprotocol = USER
temp.tx_jhopengraphprotocol {
userFunc = Heilmann\JhOpengraphprotocol\Service\OgRendererService->main
type = {$plugin.tx_jhopengraphprotocol.type}
image = {$plugin.tx_jhopengraphprotocol.image}
sitename = {$plugin.tx_jhopengraphprotocol.sitename}
description = {$plugin.tx_jhopengraphprotocol.description}
}
page.669 < temp.tx_jhopengraphprotocol
So I have tried page.669.image = lib.tt_news_image this was a ...
FAIL I got <meta property="og:image" content="http://domainname/lib.tt_news_image"/>
Can anyone guide me how to load the lib.tt_news_image value into the page.669.image properly? I think this is somehow related to the USER type, parameters (image, type, ...) are not interpreted by the Typo engine, but I have no clue how to get over it.
My general problem is to load that first image path to og:image meta tag, so any other solutions (not fixing this code or anything are very welcome).
Thank you!

TYPO3 News Extension list image size/position

I am using the news extension in TYPO3 6.2.14.
Two things:
1) How do I change the image size in the news list view? I need the images here to be 300px wide yet the settings only have the option for max width. Setting maxWidth to 300 gives me variable image widths between 150 and 200 at the moment.
2) I need the list view images to be above their headers. I have edited the List.html file but I don't know how to make the extension use my file instead of the default.
1) You can change the <f:image> in the Partials/FalMediaImage.html to use width and height. Here is the documentation. Or you can define the correct max width and a bigger max height and upload big images.
2) You can do it in TypoScript as it is in the documentation.
plugin.tx_news {
view {
templateRootPaths >
templateRootPaths {
0 = EXT:news/Resources/Private/Templates/
1 = fileadmin/templates/ext/news/Templates/
}
partialRootPaths >
partialRootPaths {
0 = EXT:news/Resources/Private/Partials/
1 = fileadmin/templates/ext/news/Partials/
}
layoutRootPaths >
layoutRootPaths {
0 = EXT:news/Resources/Private/Layouts/
1 = fileadmin/templates/ext/news/Layouts/
}
}
}

how to use load_register in typo3

I begin with TYPO3 and I try to work with LOAD_REGISTER.
I've read multiple examples on the net and I want to try some tests but I'm not able to output the data from LOAD_REGISTER-variables.
Here's my code :
page = PAGE
page {
count = LOAD_REGISTER
count {
nbblocks.cObject = TEXT
nbblocks.cObject {
data = patate
}
}
10 = TEXT
10.value = register:nbblocks
10.wrap = <h1>|</h1>
}
Page only shows "register:nbblocks", which must be a basic mistake.
Thanks in advance for the help :-)
There are several problems with your code.
Firstly, the page.count = LOAD_REGISTER content object is not run before page.10 = TEXT, which means that the register you're creating is does not exist where you want to use it. This can be fixed by renaming page.count to page.10 and page.10 to page.20.
Secondly, you should set the value-key on nnblocks.cObject instead of the data-key.
Thirdly, you need to wrap registers used in the value-property of the TEXT-object in curly brackets ({register:nbblocks}), and lastly, you need to set stdWrap.insertData = 1 on the TEXT-object.
All in all, this gives you the following code:
page = PAGE
page {
10 = LOAD_REGISTER
10 {
nbblocks.cObject = TEXT
nbblocks.cObject {
value = patate
}
}
20 = TEXT
20.value = {register:nbblocks}
20.wrap = <h1>|</h1>
20.stdWrap.insertData = 1
}

With TypoScript, how to modify a global setting per content element

The background: I am using ext:a21glossary, but I would like to disable it's replacing of for certain types of content elements. Actually, not for cTypes, but depending on what is selected via header_layout.
Now the question is more general: is it possible to access a general setting per Content element independently?
That's my basic, often-used way to use header_layout to wrap content elements:
tt_content.text.stdWrap.outerWrap.cObject=CASE
tt_content.text.stdWrap.outerWrap.cObject{
key.field = header_layout
default=TEXT
default.value=<section class="clearfix" id="c{field:uid}">|</section>
default.insertData = 1
4=TEXT
4.value=<section class="clearfix lit-container" id="c{field:uid}">|</section>
4.insertData = 1
}
So just for daring, I tried this (config.tx_a21glossary.noglossary=1 being the desired setting for that CE):
config.tx_a21glossary.noglossary.cObject = CASE
config.tx_a21glossary.noglossary.cObject {
key.field = header_layout
default=TEXT
default.value= 0
4 = TEXT
4.value = 1
}
Of course, this wouldn't work.
Before I look further: is this approach (modify a global setting per CE) possible at all?