2

在 TYPO3 6.2(刚从 4.5 升级)中,我有一个带有图像的 TMENU,使用 NO 中的 cObject 根据需要构建菜单。

它以主要语言工作,但在第二语言的前端,图像不会被渲染 - 除非它们被填充到第二语言的媒体字段中。

您如何强制 FILES 引用原始语言的媒体字段?在我的情况下,总是。在其他情况下,可能需要备用解决方案。

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 在 forge 上有许多与媒体字段/FAL 后备相关的错误,例如这个。但我有一种感觉,这可能是一个更简单的问题。

4

5 回答 5

2

mergeIfNotBlank现在不见了,目前的解决方案(TYPO3 8.7)似乎是设置

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

但基于https://forum.typo3.org/index.php/t/217033/-typo3-ug-freiburg-media-feld-in-den-seiteneigenschaften(谢谢)有这个片段。它也适用于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
                }
            }
        }
    }
}

这行得通!

于 2018-06-21T21:04:31.397 回答
1

根据 Urs 的回答,这里有一个细微的变化。

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
}

体液:

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

优点:您可以在模板中定义裁剪、替代文本等。

于 2018-11-21T13:45:44.470 回答
0

您可能想尝试将TCA字段的media设置为l10n_mode => mergeIfNotBlankhttp://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#columns-properties-l10n-mode

将其放入typo3conf/AdditionalConfiguration.php

$TCA['pages']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
于 2015-02-24T12:06:09.143 回答
0

由于此问题来自 Februari,因此您现在可能已经找到了解决方案。我刚刚遇到了这个问题并通过包括以下内容解决了它:

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

在我的 ext_tables.php

于 2016-06-08T15:16:20.417 回答
0

使用 TYPO3 CMS 7.6,您需要从 ~/typo3_src-7.6.10/typo3/sysext/core/Configuration/DefaultConfiguration.php 中设置的 [FE][pageOverlayFields] 中排除表格页面的字段媒体,直到解决 - 请参阅 forge问题https://forge.typo3.org/issues/65863

写在你的 AdditionalConfiguration

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

或在您的扩展 ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = str_replace(',media', '', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
于 2016-08-10T11:43:15.637 回答