3

In TYPO3 6.2 (just upgraded from 4.5) I have a TMENU with Images, using a cObject in NO to build the menu as desired.

It works in the main language, but in the second language's frontend, the images are not rendered - unless they are filled in in the second language's media field.

How do you force FILES to refer to the media field of the original language? In my case, always. In other cases, a fallback solution may be desired.

temp.menu = COA
temp.menu {
  wrap = <div class="teasermenu">|</div>
  15 = HMENU
  15 {
    special = list
    //special.value.cObject < temp.displayedpages
    // recieves a list, such as:
    special.value = 1,3,9
    1 = TMENU
    1 {
      noBlur = 1
      maxItems = 16
      wrap = <ul>|</ul>
      NO {
        wrapItemAndSub = <li>|</li>
        ATagBeforeWrap = 1
        ATagParams = || || || || class="red" |*| |*|

        stdWrap.cObject=COA
        stdWrap.cObject{

          10 = TEXT
          10.field = nav_title // title
          10.wrap = <strong class="teasermenu_header">|</span></strong>

          20=FILES
          20{
            if{
              isInList.field = uid
              //value.cObject < temp.displayedpages_wimage
              // receives another list, like:
              // value = 3,9
            }
            references {
              table=pages
              fieldName=media
            }
            renderObj=IMAGE
            renderObj{
              file{
                height=80
                maxH=80
                import.data=file:current:publicUrl
              }
              altText.field=title
              titleText.field=title    
              }
            }
          } 
        }
      }
    }
}

PS there are many media field / FAL fallback related bugs on forge, e.g. this one. But I have a feeling this might be a simpler issue.

Urs
  • 4,984
  • 7
  • 54
  • 116
  • I think this is already fixed, but I might be wrong. Anyway, have you tried to add the field the the overlay fields in the Install Tool: ``[FE][pageOverlayFields] `` – pgampe Feb 22 '15 at 23:23
  • Thanks! I tried this, but no luck. But doesn't `pageOverlayFields` work the other way round anyway? I want to always use the default language field, not the overlay field. http://www.typo3-blog.com/typo3-tipps/bild-aus-seiteneigenschaften-fuer-alle-sprachen/ – Urs Feb 23 '15 at 09:09
  • Can you take a look what is inside `$data` during rendering in a non-default language? You can see the full data array by outputting ``debug:data`` in any ``getText`` property, e.g. ``dataWrap = |{debug:data}``. The individual entries can be accessed via ``field:fieldname``, e.g. ``dataWrap = |{field:uid}``. Maybe you can reuse this and run some ``RECORDS`` over it to get the original page. – pgampe Feb 24 '15 at 11:58
  • Great! I get the same values for uid and pid as in the original page, and again the same value as uid in _PAGES_OVERLAY_UID. Not sure how to add that to references, though. Will check the mergeIfNotBlank way first. – Urs Feb 24 '15 at 16:02

5 Answers5

2

mergeIfNotBlank is gone now, the current solution (TYPO3 8.7) seems to be to set

$GLOBALS['TCA']['pages']['columns']['media']['config']['behaviour']['allowLanguageSynchronization'] = 1;

But based on https://forum.typo3.org/index.php/t/217033/-typo3-ug-freiburg-media-feld-in-den-seiteneigenschaften (thanks) there's this snippet. It also works with cropVariants:

temp.bgimg_wide = CONTENT
temp.bgimg_wide{
    table = sys_file_reference
    select{
        pidInList = {$pids.pidHome}
        where = tablenames='pages' AND fieldname='media'
        orderBy = sorting_foreign
        languageField = 0
        selectFields = uid_local
        max = 1
        begin = 0
    }
    renderObj = FILES
    renderObj{
        files.stdWrap.field = uid
        renderObj = IMG_RESOURCE
        renderObj {
                file {
                    import.data = file:current:uid
                    treatIdAsReference = 1 
                    width = 1600
                    cropVariant = bgimg_wide
                }
            }
        }
    }
}

This works!

Urs
  • 4,984
  • 7
  • 54
  • 116
1

With TYPO3 CMS 7.6 you need to exclude field media of table pages from [FE][pageOverlayFields] as set in ~/typo3_src-7.6.10/typo3/sysext/core/Configuration/DefaultConfiguration.php, until it is solved - see forge issue https://forge.typo3.org/issues/65863

Write in your AdditionalConfiguration

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = 'uid,doktype,title,subtitle,nav_title,keywords,description,abstract,author,author_email,url,urltype,shortcut,shortcut_mode';

or in your Extension ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = str_replace(',media', '', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
jokumer
  • 2,249
  • 11
  • 22
1

Based on Urs' answer, here comes a slight variation.

lib.getCurrentPageMedia = CONTENT
lib.getCurrentPageMedia {
    table = sys_file_reference
    select{
        pinInList = root, this
        where = tablenames='pages' AND fieldname='media' AND uid_foreign=###pid###
        orderBy = sorting_foreign
        languageField = 0
        selectFields = uid_local
        max = 1
        begin = 0
        markers {
            pid.data = TSFE:id
        }
    }
    renderObj = TEXT
    renderObj.stdWrap.field = uid
}

Fluid:

<f:image src="{f:cObject(typoscriptObjectPath:'lib.getCurrentPageMedia')}" alt="" width="400c" height="400c" treatIdAsReference="1" class="img-responsive" />

Advantage: you can define cropping, alt-text, etc. in your template.

Markus Kappe
  • 145
  • 2
  • 6
  • This didn't work for me, since I needed the fallback to the default page media in a submenu - i had to use a viewhelper instead. – mtness Dec 20 '21 at 09:09
0

You might want to try to set the TCA of the media field to l10n_mode => mergeIfNotBlank . http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#columns-properties-l10n-mode

Put this into the typo3conf/AdditionalConfiguration.php:

$TCA['pages']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
pgampe
  • 4,531
  • 1
  • 20
  • 31
  • No luck either. Do I have to do more than clear the cache (did it in the install tool) to make the setting kick in? – Urs Feb 24 '15 at 16:14
  • Yes, clearing the system cache would be required. However clearing the cache from the Install Tool takes care of that. – pgampe Feb 26 '15 at 10:44
0

Since this issue is from Februari, you've probably found a solution by now. I just ran into this issue and solved it by including:

$GLOBALS['TCA']['pages_language_overlay']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';

in my ext_tables.php

  • do you think that might also be applied to solve extbase issues from https://forge.typo3.org/issues/57272 ? I'm having similar issues with tx_news for example... well, probably not, as mergeIfNotBlank is a candidate there as well... – Urs Jun 08 '16 at 15:26
  • I'm not sure. I need to work on FAL translations next week. Fallback to default is a requirement. I'll let you know if I'll find a way. – Gabriël Ramaker Jun 10 '16 at 14:04