2017-08-07 54 views
1

Longclaw/W new新手在這裏。 W CMS CMS提供了一個可覆蓋的get_context方法,可以將字典值傳遞到模板中。來自documentation定製Longclaw產品索引

class BlogIndexPage(Page): 
    ... 

    def get_context(self, request): 
     context = super(BlogIndexPage, self).get_context(request) 

     # Add extra variables and return the updated context 
     context['blog_entries'] = BlogPage.objects.child_of(self).live() 
     return context 

Longclaw是建立在W top頂部的電子商務項目。 Longclaw有一個名爲ProductIndex的內置頁面模型。有沒有辦法將變量傳遞到ProductIndex模板,就像我可以用get_context一樣?

回答

0

偉大的問題。目前它不支持這一點,但如果可以的話,它會很好。我建議在GitHub上提出一個問題,這樣我們無法將其發展(https://github.com/JamesRamm/longclaw

可能會動態添加該函數;

def get_context(...): 
    .... 

ProductIndex.get_context = get_context 

我沒有嘗試過,所以不能肯定它會工作!