Re: [mezzanine-users] Re: Marking Django Application Pages as Active in the Navigation

2014-04-22 Thread Stephen McDonald
Stepping through the page middleware which handles assigning the page
variable will probably shed some light:

https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/middleware.py#L91-L124


On Tue, Apr 22, 2014 at 6:09 PM, PR pavan.ri...@gmail.com wrote:

 On Monday, April 21, 2014 12:30:16 PM UTC-4, Eduardo Rivas wrote:

 The blog app defines it's own url patterns. For example, the list view
 (showing all blog posts) is mapped to /blog by default.

 It seem to be that the blog app defines / to be the list view in its
 urls.py. Mezzanine includes the blog's urls.py, adding the BLOG_SLUG prefix.

 The app I am integrating also defines it's own urls. I simply included
 these in my project's urls.py(above the mezzanine catch-all):

 (^pastes/, include('dpaste.urls.dpaste')),


 Then I created a RichTextPage with the name Pastes and no parent to
 match this url. I can successfully visit the dpaste app from the added
 navigation link. When I remove the dpaste url include, I can successfully
 visit the RichTextPage.


 The trick is in creating a page in the admin with the exact same slug.
 You have to do this to get Mezzanine to insert the page variable into your
 context. In the end, Mezzanine will merge both the context provided by the
 page and the context of your own application.

 My problem is that I have created the page with the slug but Mezzanine is
 not inserting the page variable into my context, so the navigation link
 does not receive an active class.



 I've done this in the past with a custom Portfolio app and the
 integration is seamless. If you want to inspect your template context, list
 of templates and other useful debugging info in your browser, you should
 use Django Debug Toolbar. Install it with pip install django-debug-tollbar,
 Mezzanine will activate it automatically when it detects it's installed;
 you should then get a small button in the top-right corner of your site
 when running in the development server.

 Yes I've done all this, thats how I was able to see that the template was
 not being passed the page context variable...


 Here is a related screenshot:

 https://lh4.googleusercontent.com/-lKB3QXJ_Ud8/U1YijWBoSOI/AJ0/qqZqhwwT3PU/s1600/2014-04-22-040313_1366x768_scrot.png
 You can see that a Pastes page exists and that the browser is visiting
 the /pastes/ url, however the Pastes link is not shaded as active(and
 yes the theme does define a different color for active tabs, it works
 fine for the blog app).

 The breadcrumb only exists because I hardcoded it into the template, which
 would be unneeded if the page variable was inserted.

 --
 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.




-- 
Stephen McDonald
http://jupo.org

-- 
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.


Re: [mezzanine-users] Re: Marking Django Application Pages as Active in the Navigation

2014-04-22 Thread PR
On Tuesday, April 22, 2014 4:13:20 AM UTC-4, Stephen McDonald wrote:

 Stepping through the page middleware which handles assigning the page 
 variable will probably shed some light:


 https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/middleware.py#L91-L124


Thanks! From this I noticed that the request returned by the view had no 
context_data attribute. Apparently the view needs to use 
mezzanine.utils.render instead of django's render or render_to_response in 
order to be given a context_data attribute.

For now, I will just override the urls and create custom views, but is 
there any easy way to wrap or decorate views that use Django's render?

-- 
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.


[mezzanine-users] Re: Marking Django Application Pages as Active in the Navigation

2014-04-21 Thread Eduardo Rivas
The blog app defines it's own url patterns. For example, the list view 
(showing all blog posts) is mapped to /blog by default. The trick is in 
creating a page in the admin with the exact same slug. You have to do this 
to get Mezzanine to insert the page variable into your context. In the end, 
Mezzanine will merge both the context provided by the page and the context 
of your own application.

I've done this in the past with a custom Portfolio app and the integration 
is seamless. If you want to inspect your template context, list of 
templates and other useful debugging info in your browser, you should use 
Django Debug Toolbar. Install it with pip install django-debug-tollbar, 
Mezzanine will activate it automatically when it detects it's installed; 
you should then get a small button in the top-right corner of your site 
when running in the development server.

-- 
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.