Mmmh… random.choice ? It's a function that is so underrated. Anyway, I understand your statement as to why we might not be able to implement a one size fits most approach.
Le samedi 23 mai 2015 21:33:26 UTC+2, Stephen McDonald a écrit : > > Sure, but what if a product belongs to multiple categories? > > > > On Sat, May 23, 2015 at 12:21 PM, Mathias Ettinger <[email protected] > <javascript:>> wrote: > >> I meant a shop_menu tag, the page_menu already exists. >> >> >> >> Le samedi 23 mai 2015 21:20:35 UTC+2, Mathias Ettinger a écrit : >>> >>> What about implementing a page_menu tag in >>> cartridge.shop.templatetags.shop_tags? And changing the shop/product.html >>> template to use >>> >>> {% block breadcrumb_menu %}{% shop_menu "pages/menu/breadcrumb.html" >>> %}{% endblock %} >>> >>> Is it worth taking some time to provide it in cartridge? >>> >>> >>> Le samedi 23 mai 2015 18:57:35 UTC+2, Stephen McDonald a écrit : >>>> >>>> BTW you should be able to implement your own breadcrumb logic by >>>> overriding "{% block breadcrumb_menu %}" in your product.html template - >>>> at >>>> that point you have your product variable, and access to its >>>> category/categories. >>>> >>>> That wouldn't be a "one size fits all" solution, but will absolutely >>>> work for your own project. >>>> >>>> On Sat, May 23, 2015 at 8:15 AM, Mathias Ettinger < >>>> [email protected]> wrote: >>>> >>>>> So, as I understand, you’re talking about: >>>>> https://github.com/stephenmcd/cartridge/blob/master/cartridge/shop/templates/shop/product.html#L45-L48 >>>>> >>>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fstephenmcd%2Fcartridge%2Fblob%2Fmaster%2Fcartridge%2Fshop%2Ftemplates%2Fshop%2Fproduct.html%23L45-L48&sa=D&sntz=1&usg=AFQjCNGaRwDqDpf3rqW61_9I-dIh7EfvpA> >>>>> >>>>> 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. >>>>> >>>> >>>> >>>> >>>> -- >>>> 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 [email protected] <javascript:>. >> >> 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
