TYPO3-从子页面的内容中获取菜单的缩略图 [英] TYPO3 - get thumbnail for menue from CONTENT of subpage

查看:67
本文介绍了TYPO3-从子页面的内容中获取菜单的缩略图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need a typoscript for adding a thumbnail for each menu entry by getting a pic NOT from page properties, but from first content element of a specified column.

该菜单当前的印刷文字是:它基本上会生成一个名为新闻"的子页面列表.

Current typoscript for the menu is that; it basically generates a list of subpages which a named as "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>
  }
}

从子页面的页面属性/媒体生成缩略图很容易.但是,不知道打字错误查询将如何处理子页面的内容.

It's easy to generate a thumbnail from page properties / media of the subpages. But have no idea how a typoscript-query will work for content of subpages.

非常感谢你, 托马斯

Thank you very much, Thomas

推荐答案

这是另一个具有类似方法的代码段,您可以将其用作资源.这最初是带有预告片的子页面列表,但可以轻松地成为常规菜单.

Here's another snippet with a similar approach you can use as resource. This is originally a list of subpages with teasers, but it can easily be a regular menu.

我在renderObj中使用fluidtemplates,但是您也可以使用普通的TypoScript.

I use fluidtemplates in the renderObj, but you could also work with plain TypoScript.

# 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的其中一个流体模板的示例:

Here's an example for one of the fluid templates for the 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>

相关链接:

古老的 http://www.typo3wizard.com/de/artikel/das-content-objekt.html 帮助我了解了CONTENT对象.

Ages-old http://www.typo3wizard.com/de/artikel/das-content-objekt.html has helped me understanding the CONTENT object.

https://forum.typo3.org/index .php/t/192687/content-in-tmenu 基本上是您的问题,导致select.pidInList.data = field:uid

https://forum.typo3.org/index.php/t/192687/content-in-tmenu is basically your question, resulting in select.pidInList.data = field:uid

将内容从TypoScript传递到流体模板TYPO3 7.6 中的内容是关于如何将图像获取到Fluidtemplate中的.

Pass content from TypoScript to fluid template in TYPO3 7.6 is about how to get images into the Fluidtemplate.

这篇关于TYPO3-从子页面的内容中获取菜单的缩略图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆