Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bryan Drenner 37 posts 59 karma points
    Feb 09, 2012 @ 22:37
    Bryan Drenner
    0

    Best way to redirect when a cart expires?

    I'm trying to incorporate shopping/cart features from a remote web service into my site design.  Particular pages need to check the status of the cart and redirect when items have expired, preferably before doing any further unnecessary processing or rendering.

    I can accomplish this through a child action placed at the top of an Umbraco template (view), but this seems ugly to me.  In an ordinary MVC Framework site, I would accomplish this via filters or attributes on controller methods, but this seems to be impossible with Umbraco pages.

    Is there any way to execute custom, preliminary code on a per-page basis?

    Thanks,
    Bryan

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Feb 10, 2012 @ 11:49
    Tim
    0

    You could create a base template class that inherits from the main Umbraco one, set your master pages to use that instead of umbraco/masterpages/default.master (the default one), and then add your code to the new base page. That would then get called for every page. If you just wanted the checks on certain temnplates, only use your custom base class on the templates where you want to perform the checks.

    Hope that helps!

  • Bryan Drenner 37 posts 59 karma points
    Feb 10, 2012 @ 16:40
    Bryan Drenner
    0

    Tim,

    Thanks for your reply!  I may be wrong, but your solution seems to apply to Umbraco 4.  In Umbraco 5, I suppose the equivalent of inheriting a master page would be to extend a layout.  Shazwazza.com author, Shannon Deminick, advised me via comments to look into the Tasks API.  Any thoughts on that?

    Bryan

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Feb 10, 2012 @ 16:44
    Tim
    0

    Hiya,

    Yup, my answer applies to v4, sorry I missed the MVC part! Shannons suggestions makes sense, I've not used the task API for v5 yet, so I can't advise on that sadly.

    :(

Please Sign in or register to post replies

Write your reply to:

Draft