2016-03-17 50 views
2

我想通過TypoScript讀取內容並通過自定義Fluid模板呈現它。沒有css_styled_content或fluid_styled_content。將內容從TypoScript傳遞到TYPO3中的流體模板7.6

temp.test = CONTENT 
temp.test { 
    table = tt_content 
    select.languageField = 1 
    select.selectFields = bodytext,image,header,header_link 
    select.where = colPos = 1 
    renderObj = FLUIDTEMPLATE 
    renderObj { 
    file = path/to/Teaser.html 
    } 
} 

這也適用於字符串,說

<f:debug>{data.header}</f:debug> 

但不能與

<f:debug>{data.image}</f:debug> 

只返回圖像的數量。

現在,在一個典型的TypoScript RenderObj(也許COA),你會補上一句

10 = FILES 
10 { 
    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 
    } 
} 

雖然現在,我們要做的是,在流體模板。但如何解決FAL圖像將其傳遞給流體模板?

回答

3

您應該可以使用TYPO3\CMS\Frontend\DataProcessing\FilesProcessor數據處理器爲您提取文件數據,以便您可以在模板中使用{files}來訪問它。

renderObj = FLUIDTEMPLATE 
renderObj { 
    file = path/to/Teaser.html 
    dataProcessing { 
    10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor 
    10.references.fieldName = image 
    } 
} 
+0

哇,非常感謝,我在哪裏可以找到? – Urs

+0

啊,在這裏! https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html – Urs

1

主要問題是所有圖像信息都存儲在不同的表中,名爲「sys_file_reference」。選擇「tt_content.image」不會幫你在這裏。有兩種方法可以解決這個問題,恕我直言。

1)創建您自己的viewhelper。這個VH可以用來查詢圖像here

2)創建一個小的TypoScript庫,並將其用作流體模板中的f:cObject。這被描述爲here

我不是說我的解決方案是最好的。但這是我所知道的唯一一個。期待看到更好的解決方案;)

+0

謝謝 - 我想Daniel有一個! – Urs

+0

Thx爲您的答案。我也更喜歡丹尼爾的解決方案! –