2015-09-12 81 views
0

如何建立一個子內容使用Typo腳本參照父母的header_link領域頁面(嵌套內容)?TypoScript/Typo3:如何使用header_link值構建頁面的子內容?

所需的輸出是一樣的東西:

<h1>Title of parent</h1> 
<p class="prt">Body of parent</p> 
<h3>Title of Child</h3> 
<p class="cld">Contents of child</p> 

我的Typo腳本樣本:

temp.myParentVal = CONTENT 
temp.myParentVal { 
    table = tt_content 
    select { 
    begin = 1 
    orderBy = sorting 
    where = (colPos = 1) 
    } 
    renderObj = COA 
    renderObj { 

    10 = TEXT 
    10 { 
    required = 1 
    wrap = <h1> | </h1> 
    stdWrap.field = header 
    } 
    20 = TEXT 
    20 { 
    required = 1 
    wrap = <p class="prt"> | </p> 
    stdWrap.field = bodytext 
    } 


    #                # 
    # WHAT SHOULD I DO HERE TO SHOW THE CHILD CONTENT OF THIS PAGE # 
    # (REFERENCED BY header_link FIELD IN THE PARENT'S ROW),  # 
    # WHICH HAS THE FORMAT OF <child_pid#child_uid>, EG.'11#28'  # 
    #                # 


    stdWrap.wrap = <div> | </div> 
} 

我想利用母公司的header_link字段的值來生成用於孩子的內容。 (我使用TYPO3 v 6.2.14)

回答

1

您可以使用嵌套CONTENT元素,並通過正則表達式拆分header_link這樣的:

30 = CONTENT 
30 { 
    table = tt_content 
    select { 
    uidInList { 
     field = header_link 
     stdWrap.replacement.10 { 
     search = /^.+#/ 
     replace = 
     useRegExp = 1 
     } 
    } 
    pidInList { 
     field = header_link 
     stdWrap.replacement.10 { 
     search = /#.+$/ 
     replace = 
     useRegExp = 1 
     } 
    } 
    } 
    renderObj = COA 
    renderObj { 
    10 = TEXT 
    10.value { 
     required = 1 
     wrap = <h3> | </h3> 
     field = header 
    } 
    20 = TEXT 
    20.value { 
     required = 1 
     wrap = <p class="cld"> | </p> 
     field = bodytext 
    } 
    } 
} 

另外,我想建議你使用field財產直接在TEXT元素(工作)。但我在文檔中查詢到:

stdWrap屬性在對象的根級別上可用。這是非標準的!通過訪問屬性「stdWrap」,您應該將這些stdWrap屬性一致地用於其他cObject的屬性。

https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Text/Index.html

由於valuestdWrap對象,你可以像我上面那樣使用它。

+0

這樣做的竅門,謝謝! :) – Ren

相關問題