hooking one's code into right position

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Hi,

Looking at my store I just thought it might be beneficial to put some stuff into the shipping cart page. Sure I can go into ShippingCart/Cart.cshtml and stick stuff in therek, but it would be nice to be able to put some stuff there whilst keeping my code separated as much as possible from nop commerce code. The benefit is easier merging next time nop team adds some great new feature..

@sections won't cut as they would require me to put code into cart.cshtml .. but maybe the cart.cshtml could be modified to have something along the lines of Html.Action("UserDefined", "CartPageTop")? I all the CartPageTop method would do is load approripate empty CartPageTop.cshtml view where developers could stick their stuff all in one place and be pretty sure it won't get corrupted by next nop release ..

I am using CartPageTop just as an example. EverywhereHeaderBelowMenu, HopePageHeaderBelowMenu, EverywhereBelowFooter, OrderPlacedHeader etc etc. also come to mind ..

Filip

P.S. Maybe this is part of a more general discussion on how to make Nop more themable..
12 years ago
To demonstrate what I mean about above here is an example of a typical task someone working with nop commerce might have..

Task a hand is: show something to user in the header section (above menu) but _only_ on Home page.

Solution 1 (doesn't work)
Defining a @RenderSection in _root.cshtml and @section in Home/Index.cshtml fails. MVC3 doesn't handle section with nested includes.

Solution 2 (works but is ugly)
The approach that works is putting your own child action in _root.cshtml and making it show your code only if called from home page. This is how it could be done:


        [ChildActionOnly]
        public ActionResult HomePageOnly()
        {
            if (ControllerContext.ParentActionViewContext.RouteData.Values["action"] == "Index"
                && ControllerContext.ParentActionViewContext.RouteData.Values["controller"] == "Home")
            {
                return PartialView();
            }

            //every other page get's nothing..
            return Content("");            
        }


Of course this gets called every time and is not an elegant solution at all.

Looking for suggestions.

Filip
12 years ago
Maybe we need more widget zones and views that control how they are displayed for each zone?
12 years ago
The work item is already created. Please vote here
12 years ago
Widgets are a great addition to nopcommerce without doubt. the one thing that is limiting its capabilities is the ability to define layouts outside the code which would allow anybody to create his own themes, themes with multiple layouts ...
themes can be installed and layouts are dynamically read and parsed for zones in which widgets can be placed.
if we achieve this, everything in nop could become a widget (all the existing features could be converted to widgets and managed from a user interface rather then changing the html in pages ...
the site design would them focus on designing widgets rather then designing pages and sites.
a good example for this would be orchard cms.

I already voted on codeplex and added the same comment.
12 years ago
Please see changeset 0aa97a13e295 and let me know your thoughts. Maybe some suggestions about new widget zones?
11 years ago
Is there a way that we can get some documentation on where the new widget zones are?  I'm trying to make a new widget plugin and can't find a list for the zones.  The designers guide now outdated.
11 years ago
ok, I have 193 widget zone names identified and listed.  The list is too long to post here in the forums, so if anyone needs it let me know.  Thanks.
11 years ago
I just did this the other day.  So I figure I'll post it at nopTools.com for all:

List of Widget Zones in nopCommerce



(P.S.  Andrei - I borrowed the picture from the nopC docs page.  If that's a problem, let me know :)
11 years ago
New York wrote:
I just did this the other day.  So I figure I'll post it at nopTools.com for all:

List of Widget Zones in nopCommerce



(P.S.  Andrei - I borrowed the picture from the nopC docs page.  If that's a problem, let me know :)


Thanks, that's excellent.  Now the next logical step would be to have these in a dictionary object (showing friendly name and system name), or something like that, so that you can easily reference it within the code, especially when writing a controller to pupulate a dropdown for the configure view.  Also would be good to have a "getAllWidgetZones" function within one of the appropriate service classes.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.