2017-10-18 37 views
0

我有一個簡單的後端模塊,您可以在其中切換或創建新的「主題」。爲了簡單起見,假設模型僅包含徽標和顏色代碼。在我的Typo腳本設置我使用下面的代碼從DB獲得的項目:如何將CONTENT - > renderObj分解爲使用typoscript的變量?

temp.theme= CONTENT 
temp.theme{ 
      select{ 
       ... 
      } 
      renderObj = COA 
      renderObj { 
        #theme color 
        10 = TEXT 
        10.field = color 
        ... 
        #theme logo 
        40 = FILES 
        40{ 
         references { 
           ... 
         } 
         renderObj = IMAGE 
         renderObj { 
           wrap = <div class="logo">|</div> 
           file.import.data = file:current:originalUid 
         } 
        } 
      } 
} 

我該如何分割該對象到變量? 這不會工作,但我想這是我想要達到良好的表現:

lib.logo = COA 
lib.logo < temp.theme.renderObj.40 

另外我想設置顏色如下(顯然這也不工作):

page.cssInline.1010 < temp.theme.renderObj.10 

有沒有更好的方法來實現我想要做的?什麼是工作,到目前爲止對我來說是複製這個對象,然後取消設置什麼我不使用:

temp.logo = COA 
temp.logo{ 
      10 < temp.theme 
      10.renderObj.10 > 
      ... 
      #10.renderObj.40 > 
      ... 
} 

我敢肯定,有一個簡單的方法,但我無法找到它。

+0

你能解釋你想在頁面上輸出什麼嗎? –

+0

是的,例如,我想呈現這樣的標誌:雖然它以這種方式工作,但我想知道是否有更優雅的解決方案給我問題,我可以像這樣直接指定徽標:lib.logo

+0

如果您的PAGE對象使用FLUIDTEMPLATE創建頁面,則可以將「變量」分配給您的流體模板:https:/ /docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html#variables –

回答

1

您必須詳細瞭解Typocript的運算符和cObjects。

lib.logo = COA 
lib.logo < temp.theme.renderObj.40 

這使得lib.logo成爲一個COA cObject,然後你只複製temp.theme裏面的renderObj。但是renderObj沒有它所屬的CONTENT對象是沒有用的。所以將它改爲

lib.logo < temp.theme 

它會將整個對象複製到它。您以前不必將其聲明爲COA。也許你甚至不需要臨時工。對象 - 您可以使整個lib.logo成爲CONTENT對象。

這同樣適用於page.cssInline.1010 - 你不能只複製renderObj。整個對象複製到或使其直接成爲內容對象:

page.cssInline.1010 = CONTENT 
page.cssInline.1010 { 
    select{ 
    ... 
    } 
    renderObj = TEXT 
    renderObj { 
    field = color  
    } 
} 

存儲的renderObj的一些臨時結果的唯一方式是使用LOAD_REGISTER對象:https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/LoadRegister/Index.html?highlight=load_register

所有cObjects文檔:https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Index.html 運營商:

相關問題