2017-08-07 39 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 

我没有尝试过,所以不能肯定它会工作!