Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Menu TYPO3-从子页面的内容中获取菜单的缩略图_Menu_Typo3_Typoscript - Fatal编程技术网

Menu TYPO3-从子页面的内容中获取菜单的缩略图

Menu TYPO3-从子页面的内容中获取菜单的缩略图,menu,typo3,typoscript,Menu,Typo3,Typoscript,我需要一个打字脚本,通过不是从页面属性而是从指定列的第一个内容元素获取图片,为每个菜单项添加缩略图 菜单当前的排印字体是:;它基本上会生成一个名为news的子页面列表 temp.newsPage = COA temp.newsPage.40 = HMENU temp.newsPage.40 { special = directory special.value = {$plugin.tx_rstwstdtpl.settings.menuNewsPagesStart} includeN

我需要一个打字脚本,通过不是从页面属性而是从指定列的第一个内容元素获取图片,为每个菜单项添加缩略图

菜单当前的排印字体是:;它基本上会生成一个名为news的子页面列表

temp.newsPage = COA
temp.newsPage.40 = HMENU
temp.newsPage.40 {
  special = directory
  special.value = {$plugin.tx_rstwstdtpl.settings.menuNewsPagesStart}
  includeNotInMenu = 1 
  wrap = <div class="news-latest-container">|</div>
  1 = TMENU
  ### sortieren nach DATUM ###
  1.alternativeSortingField = lastUpdated  DESC
  ### sortierung ende ###
  1.NO.allWrap.insertData = 1
  1.NO.allWrap = <div class="news-latest-item">|</div>
  1.NO.doNotLinkIt = 1
  1.NO.doNotShowLink = 1
  1.NO.before.cObject = COA
  1.NO.before.cObject {
    5 = COA
    5.10 = TEXT
    5.10.value = <div class="selector date
    # DATUM
    5.30 = TEXT
    5.30.field = lastUpdated
    5.30.strftime=%Y
    5.90 = TEXT
    5.90.value = ">
# letzte Aenderung
    10 = TEXT
    # anzeige NewsDATUM = metadaten - lastupdated
    10.field = lastUpdated
    # 10.strftime=%d.%m.%Y %H:%M
    10.strftime=%d.%m.%Y
    10.wrap = <span class="news-latest-date">|</span><br />
# title
    20 = TEXT
    20.field = title
    20.wrap = <h2><span class="news-latest-header">|</span></h2>
    20.typolink.parameter.field = uid
# text
    30 = TEXT
    30.field = abstract
    30.crop = {$plugin.tx_rstwstdtpl.settings.teaserTextLength}|&nbsp;...|1
    30.wrap = <p>|</p>
    30.required = 1

    40 = TEXT
    40.value = </div>
  }
}
从子页面的页面属性/媒体很容易生成缩略图。但我不知道打字脚本查询如何处理子页面的内容

多谢各位,
Thomas

您需要的是一个select来收集tt_内容记录的UID,这些记录属于您当前生成摘要的页面中的特殊列。 这可以通过打印脚本和对象记录或内容来完成

例如,在35处使用before.cObject,如下所示:

35 = CONTENT
35 {
  table = tt_content
  select {
    // we are in context of that page, so data is the pages record
    pidInList.field = uid
    // the special column:
    where = colPos = 123
    // select only content with images (something like:)
    andWhere = media > 0
    // one image is enough
    max = 1
  }
  // now we have to do it a little more complicated as images are 
  // handled with FAL records
  renderObj = FILES
  renderObj  { 
    references { 
      table = tt_content
      // we are now in context tt_content 
      uid.data = current:originalUid // current:uid
      // depending whether you use CSC or FSC:
      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 = pid
    } 
    maxItems = 1 
  }
我希望这是正确的,因为我收集它没有经过验证


顺便说一句:使用包装,例如使用数据包装,您甚至可以插入数据,而不是非常大的COA,因此您可以确保匹配开始和结束标记。

这里是另一个具有类似方法的片段,您可以将其用作资源。这本来是一个带有摘要的子页面列表,但它可以很容易地成为常规菜单

我在renderObj中使用fluidtemplates,但您也可以使用纯打字脚本

# TEASER NAV
#####################################################################

lib.subpages_teaser = HMENU
lib.subpages_teaser {
  // I use a directory menu here
  special = directory
  // but this could also be a normal menu without "special" property
  // directory menu entrypoint
  special.value = 123
  // alternatively: entrypoint for use as teasers of subpages
  // special.value.data = leveluid:-1

  // exclude shortcut
  excludeDoktypes = 4
  // but show "not in menu" pages (if needed)
  //includeNotInMenu = 1
  1 = TMENU
  1 {
    NO {
      // * If you want to link only certain parts of the following COA:
      // doNotLinkIt = 1
      allWrap = <section>|</section>
      stdWrap.cObject = COA
      stdWrap.cObject {
        10 = COA
        10 {
          // * If doNotLinkIt is enabled, link this part
          // stdWrap.typolink.parameter.data = field:uid
          // get data from Content Element
          10 < styles.content.get
          10 {
            select {
              // https://forum.typo3.org/index.php/t/192687/content-in-tmenu
              selectFields = image
              pidInList.data = field:uid
              where = colPos=13
            }
            // and process it via a fluidtemplate
            renderObj = FLUIDTEMPLATE
            renderObj {
              // https://stackoverflow.com/questions/36072136/pass-content-from-typoscript-to-fluid-template-in-typo3-7-6
              file = path/to/my/partials/TeaserImage.html
              dataProcessing {
                10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
                10.references.fieldName = image
              }
            }
          }
          20 = TEXT
          20 {
            field = nav_title // title
            wrap = <h2>|</h2>
          }
          // LEAD
          30 < styles.content.get
          30 {
            select {
              selectFields = header
              pidInList.data = field:uid
              where = colPos=2
            }
            renderObj = FLUIDTEMPLATE
            renderObj {
              file = path/to/my/partials/TeaserLead.html
            }
          }
        }
      }
    }
  }
}
以下是renderObj的一个流体模板示例:

<figure>
  <f:if condition="{files.0}">
    <f:then>
    <img src="<f:uri.image image="{files.0}" width="419" height="279c"/>"
      alt="{files.0.alternative}"
      />
    </f:then>
    <f:else>
      <f:image src="/fileadmin/my/images/grey.png" width="600" height="750c"/>
    </f:else>
  </f:if>
</figure>
相关链接:

Ages old帮助我理解内容对象

基本上是您的问题,结果是select.pidInList.data=field:uid

是关于如何将图像放入Fluidtemplate的