So, as I understand, you’re talking about: https://github.com/stephenmcd/cartridge/blob/master/cartridge/shop/templates/shop/product.html#L45-L48 not displaying Shop > Category > Subcategory > Product.title but only Shop > Product.title
The block uses the page_menu template tag. But also uses the PageMiddleware mechanisms because the page_menu function uses the page object populated in the context by the PageMiddleware: https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/templatetags/pages_tags.py#L57-L64 PageMiddleware rely on the PageManager to query the pages in the hierarchy of the page we are curently on: https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/middleware.py#L76-L80 You can see in PageMiddleware that the hierarchy is queryed by searching for pages with their slug being a subset of the slug we are currently on: https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/pages/managers.py#L68-L69 And here is the problem you are facing. Since the url of your product is SHOP_SLUG/product/PRODUCT_SLUG, only SHOP_SLUG is being matched as a valid page, hence the short breadcrumb. I haven't thought of a way to solve it efficiently, but suggestions are welcome. Le samedi 23 mai 2015 11:51:42 UTC+2, David Unric a écrit : > > Yes, you've nailed it. Thanks for rephrasing the question. > > It seems Product model derives only from Displayable, unlike Category > which derives from Page, so it won't be handled with PageMiddleware. > I'd guess for Product it would be prefixed directly by its app_label. > > After inserting tracing output in mentioned pages_tags.py, shop_product > view receives in context both Shop and Category instances, but the former > is used. > > > On Saturday, May 23, 2015 at 3:53:13 AM UTC+2, Chris Trengove wrote: >> >> As I understand it, this happens in PageMiddleware (pages/middleware.py) >> which is responsible for coming up with a "page" to add to the template >> context. This happens as well for non-page views, like blog pages and shop >> products, in which case the "page" that gets added to the context is the >> root "blog" or "shop" page. >> >> For shop products, I think a useful feature would be to have the context >> page be the category with the deepest (most specific) "path". So if a >> product was in "Shop > Mens Wear > Shirts" and "Shop > Mens Wear" (as a >> featured product), then when viewing the product, the "page" set in the >> context would be "Shirts", so that the breadcrumbs then showed "Shop > Mens >> Wear > Shirts" and not (as happens at present) "Shop". >> >> So, the question is how best to achieve this, presumably by modifying >> PageMiddleware in some way. >> >> On Friday, May 22, 2015 at 11:11:51 PM UTC+10, David Unric wrote: >>> >>> Hello, >>> >>> how can I configure/tweak Mezzanine *cartridge.shop.models.Product* >>> won't be prefixes with *Shop* in menus and breadcrumbs ? >>> >>> For example I've created product category Pages named "Cars" and >>> "Acessories" and each product belongs only to one of them. >>> Both categories are rendered as root in page_menu >>> "pages/menus/tree.html" (bellow Shop), links in category view (including >>> nested ones) correspond to current category in a categories tree. So far >>> so good. >>> However when navigate to a specific product, instead of real parent >>> categories path, page_menu places product directly as a descendant of >>> *Shop*, which is not correct. >>> >>> It seems the logic is in Mezzanine's pages_tags.py in >>> pages/templatetags, but having a harder time to completely understand it, >>> incl. where *menu_pages* in context comes from etc. >>> >>> I do not know if I'am on the right track and would welcome if anybody >>> can give me an advice how Cartridge products to be linked as descendants of >>> their primary category instead of a generic Shop ? >>> >>> Thanks. >>> >> -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
