2017-03-16 86 views
1

訪問靜態頁面屬性有一些方法可以將靜態頁面的額外字段中的值提取到某個組件中?OctoberCMS |從組件

我需要實現AJAX處理器...

我可以加載靜態頁面的內容,但是,我需要的是由用戶設置好的屬性...

enter image description here

我需要的代碼的例子......我可以加載靜態頁面內容作爲Partial #noobhacks :)

public function onOpenHome() 
{ 

    $this->page['categories'] = Category::all(); 

    return [ 
     //'main' => $this->renderPartial('home'), 
     'main' => $this->renderPartial('../content/static-pages/index'), 
     '.home_categories' => $this->renderPartial('work_list_categories_post') 
    ]; 
} 

或內容:

[viewBag] 
== 
<main class="home_container" __color="{{ color }}"> 
    <section class="box"> 
     {% content '/static-pages/index.htm' %} <!-- <<<<------ --> 
     {{ content |raw }} 
    </section> 
</main> 

但我不IDEIA如何訪問到ColorPicker的財產color

回答

2

組件對象使用自己的姓名(或別名)可供選擇。這意味着「顏色」的值應該可以通過{{ viewBag.color }}獲得。

+0

您好! 不...我無法訪問它... 不幸的是,我需要離開我的想法,並改變項目結構.... 今天我找到了https://octobercms.com/support/article/ob -19 因此,我將按照步驟進行操作,並且我將執行類似於靜態頁面的操作,並且將使我所有的AJAX更加輕鬆...但是非常感謝!你的CMS真棒! –