簡體   English   中英

錯別字7.4。 通過打字稿獲取tt_content textmedia圖像

[英]typo3 7.4. get tt_content textmedia images via typoscript

我正在創建一個新頁面,並嘗試使頁腳在后端中可編輯。 因此,我創建了一個新的tt_content textmedia元素,並通過拼寫將其保存到變量中:

footerdata = RECORDS
footerdata {
  tables = tt_content
  source = 165
  dontCheckPid = 1
  conf.tt_content = COA
  conf.tt_content {
    10 = TEXT
    10.field = header
    10.wrap = <h1>|</h1>

    20 = TEXT
    20.field = bodytext
    20.parseFunc =< lib.parseFunc_RTE
    20.wrap = <div>|</div>
  }
}

在我的模板中,我只是將其添加到頁腳中:

<f:format.raw>{footerdata}</f:format.raw>

這對於標題和文本效果很好,但是我也根本找不到如何對圖像執行此操作。 任何人都有任何教程,鏈接等,可以在哪里查找? 我試圖用谷歌搜索這個問題,但Typo3 7似乎是新手,沒有任何可用的可用提示。

提前致謝!

我不太喜歡RECORDS對象。 我總是覺得它是神秘的。

我通常將此類條目放在單個sysfolder中,然后獲取該pid的所有內容。

老派做法:

lib.address = CONTENT
lib.address {
    wrap = |
    table = tt_content
    select.languageField = sys_language_uid
    # uncomment if you want to be more specific
    # select.selectFields = bodytext,image,header,header_link

    # or if you want to limit by colPos
    # select.where = colPos = 6

    # This is your "Address" Sysfolder's pid
    # It's nice to keep such hardwired values in constants
    # ... but of course you can also just do = 123
    # select.pidInList = {$pidAddress}

    # here, the rendering is done
    renderObj=COA
    renderObj{
      wrap = |
      # That's how you process the FAL files
      # This is since TYPO3 6.2 btw
      5 = FILES
      5 {
        required = 1
          references {
            table = tt_content
            fieldName = image
          }
          renderObj = IMAGE
          renderObj {
              file.import.data = file:current:originalUid // file:current:uid
              file.width=654
              file.height = 327c
              # stdWrap.typolink.parameter.data = file:current:link
              altText.data = file:current:description // file:current:title // file:current:alternative
          }
      }
      # Let's say you want the other content here
      10 = COA
      10 {
            1=TEXT
            1{
                required=1
                wrap=<h1>|</h1>
                field=header
            }
            2=TEXT
            2{
                required=1
                wrap=<div>|</div>
                field=bodytext
            }
        }

     }
}

然后在頁面模板中,按如下方式訪問cObject

<f:cObject typoscriptObjectPath="lib.breadcrumb" />

另外,這是一種更現代的方法,該方法使用流體模板作為renderObj:

lib.address = CONTENT
lib.address {
  # same as above
  wrap = |
  table = tt_content
  select.languageField = sys_language_uid

  # here it's getting different
  renderObj = FLUIDTEMPLATE
  renderObj {
    file = {$customContentTemplatePath}/MyFile.html
    layoutRootPath = {$customContentLayoutPath}
    partialRootPath = {$customContentPartialPath}
    dataProcessing {
      // https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html
      // available data processors: SplitProcessor, CommaSeparatedValueProcessor, FilesProcessor, DatabaseQueryProcessor, GalleryProcessor
      10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
      10.references.fieldName = image
    }
    //settings {
    // type = some_setting
    //}
  }
}

這是一個示例,我將如何使用流體模板渲染該對象, 完全可以選擇使用VHS viewhelper擴展(EXT:vhs)

{namespace v=FluidTYPO3\Vhs\ViewHelpers}

<div class="small-12 medium-6 large-4 columns">
    <f:for each="{files}" as="file">
        <v:media.image src="{file}" srcset="1200,900,600" srcsetDefault="600" alt="{file.alternative}" treatIdAsReference="1"/>
    </f:for>
    <h1>{data.header}</h1>
    <div>{data.bodytext}</div>
</div>

<f:comment>
// memory help for debugging:
<f:debug>{data}</f:debug>
<f:debug>{settings}</f:debug>
<f:debug>{file}</f:debug>
</f:comment>

更正確的是,renderObj應該由DataProcessor代替 我還沒有准備好。

另一種方法是使用VHS擴展並使用render.record viewhelper:

https://fluidtypo3.org/viewhelpers/vhs/master/Render/RecordViewHelper.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM