【问题标题】:TYPO3 - get thumbnail for menue from CONTENT of subpageTYPO3 - 从子页面的内容中获取菜单的缩略图
【发布时间】:2016-12-05 15:37:28
【问题描述】:

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

菜单的当前排版是这样的;它基本上会生成一个名为“新闻”的子页面列表。

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>
  }
}

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

非常感谢, 托马斯

【问题讨论】:

    标签: menu typo3 typoscript


    【解决方案1】:

    您需要一个选择来收集 tt_content 记录的 uid,这些记录属于您当前为其生成预告片的页面中的特殊列。
    这可以通过对象 RECORDS 或 CONTENT 以印刷方式完成。

    例如在 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 
      }
    

    我希望这是正确的,因为我未经验证就收集了它。

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

    【讨论】:

      【解决方案2】:

      这是另一个可以用作资源的类似方法的 sn-p。这最初是带有预告片的子页面列表,但它很容易成为常规菜单。

      我在 renderObj 中使用流体模板,但您也可以使用纯 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 的流体模板之一的示例:

      <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 对象。

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

      Pass content from TypoScript to fluid template in TYPO3 7.6 是关于如何将图像放入 Fluidtemplate。

      【讨论】:

        猜你喜欢
        • 2012-08-28
        • 1970-01-01
        • 1970-01-01
        • 2021-03-09
        • 1970-01-01
        • 2020-05-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多