On Wed, May 4, 2016 at 7:29 AM, Christian Hill <xn.h...@gmail.com> wrote:
> I have looked through the Mezzanine documentation, but not found a > solution to this -- I have a RichTextPage, "Foo", with child pages "Bar 1", > "Bar 2", etc. I'd like the Foo page and all its children to have the user > login/logout panel on them (but not have it on other pages of my site). > > I can create a custom template in foo/templates/pages/page.html with {% > overextends "pages/page.html" %} in it, but this affects all Pages rendered > to the page.html template. > > Conversely, I can call it foo/templates/pages/foo.html but then it only > affects the root Foo page and not its Bar 1, Bar 2, etc. children. > > These pages are ordinary old RichTextPages, so I don't want to subclass > Page simply to customize the page.html template a little bit. I feel sure > I'm missing something, but I don't know what. Can anyone offer any > suggestions? > But this is the way to go - IMO - I don't see what's wrong with subclassing (are you afraid of perfomace overhead?), you need a way to differentiate those pages from the others... For instance, you can do the convention to start the pages with some prefix (like "login_") and then check at some place (the template or template tag or maybe view) if the slug starts with the prefix then use another template or render the login. But this is not worth the hassle: you will need to hack on several places and you will end with your codebase obscured. There are even "darker" ways of doing it... :) Instead: # On models class PageWithLogin(Page, RichText): class Meta: verbose_name = _("Page with Login") verbose_name_plural = _("Pages with Login") # On admin class PageWithLoginAdmin(PageAdmin): fieldsets = deepcopy(PageAdmin.fieldsets) admin.site.register(PageWithLogin, PageWithLoginAdmin) and then you create "pagewithlogin.html" template which extends the richtextpage with the login form. Then you can create those pages from the admin and arrange them in the "tree" just as regular pages. Cheers, Rodrigo > > Chris > > -- > You received this message because you are subscribed to the Google Groups > "Mezzanine Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to mezzanine-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.