Checkout Stopped Working

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 anni tempo fa
asoares wrote:
if you didn't modify both web.config (in your theme's view folder and in the main app's view folder)


But I have, I provided the code in my previous posts :(

Here's the code for my Themes/Theme00/Views/Home/Index.cshtml.

As you can see, it doesn't have any calls to any PartialViews.

When you say Restart Visual Studio ? << How does one do that ? Cause I just stop the application, then go to Build > Clean, then Build > Build Solution

Is that right ? I also manually stop the server instance.

:(
12 anni tempo fa
@Html.Action("HomepageCategories", "Catalog") does not have its layout processed, it can only be used inside another view.

When I say restart visual studio, I mean close it and restart it (the visual studio application). I've seen cases where the default page was not refreshed when changed until I restarted visua studio when running in debug mode (I can't explain that).
12 anni tempo fa
asoares wrote:
@Html.Action("HomepageCategories", "Catalog") does not have its layout processed, it can only be used inside another view.


But the above is also how the default (Dark Orange) { Home/Index.cshtml } is !

Does that mean, with this method, I can't use PartialView anymore :s How am I suppose to get around this ?

Thanks
12 anni tempo fa
No its alright the way it is. Html.Action process the asked view through the view engine. I think that for the moment, the override is called only in the partial view that you have overriden. It should also be called in views that you haven't overriden given you modified both web.config and restarted visual studio.

One thing you can do to make sure that the code is used is to go in a view that has a layout and that you haven't overriden (for instance Home/Index.cshtml if you haven't overriden it), put a breakpoint on the Layout = "..." statement. If the ExtendedWebViewPage is used, hitting F11 when the breakpoint is hit should take you to the overriden Layout property.

I'm afraid I can't help you more than the info I'm given you so far. Good luck.
12 anni tempo fa
Thank you So much Asoares. It finally worked. :)
12 anni tempo fa
Thanks for this tip, it seems to work!
12 anni tempo fa
My bad, I fixed the issue :) lol thanks Asoares for such a nifty solution to a big problem.
12 anni tempo fa
Ciwan wrote:
Are there any limitations or undesired side effects to the above code ?

I'm just curious .. cause if only a few lines of code allows such good functionality, why didn't the development team behind nopCommerce use it !


No one from Nop Team answered.  Will this change be made for 2.20?  (please :)


The solution worked for me (thanks asoares), but it was a bit painful going through 3 pages of this thread and the issues encountered, so here's the summary...


To create a custom Theme that includes Views, these modifications are needed to get all custom Views processed thru view engine (including those used as Layout - e.g.  _Root.cshtml, _ColumnsThree.cshtml, etc.)

1) Modify file
  \src\Presentation\Nop.Web.Framework\ViewEngines\Razor\WebViewPage.cs  

before line
    public abstract class WebViewPage : WebViewPage<dynamic>    

paste this code

    public abstract class ExtendedWebViewPage<TModel> : Nop.Web.Framework.ViewEngines.Razor.WebViewPage<TModel>
    {
        public override string Layout
        {
            get
            {
                var layout = base.Layout;

                if (!string.IsNullOrEmpty(layout))
                {
                    var filename = System.IO.Path.GetFileNameWithoutExtension(layout);
                    ViewEngineResult viewResult = System.Web.Mvc.ViewEngines.Engines.FindView(ViewContext.Controller.ControllerContext, filename, "");

                    if (viewResult.View != null)
                    {
                        layout = (viewResult.View as RazorView).ViewPath;
                    }
                }

                return layout;
            }
            set
            {
                base.Layout = value;
            }
        }
    }

    public abstract class ExtendedWebViewPage : ExtendedWebViewPage<dynamic>
    {
    }


2) Create a Theme subfolder, and copy needed subfolders/css/Views/etc.
(just copy the files you actually modify to make sure to use the latest version of the views you don't)
    \src\Presentation\Nop.Web\Themes\<your theme folder>

    
3) In web.config files - both
    \src\Presentation\Nop.Web\Views\Web.config
    \src\Presentation\Nop.Web\Themes\<your theme folder>\Views\Web.config

replace
    <pages pageBaseType="Nop.Web.Framework.ViewEngines.Razor.WebViewPage"> -->
with
    <pages pageBaseType="Nop.Web.Framework.ViewEngines.Razor.ExtendedWebViewPage">
    
    
4) Build App
12 anni tempo fa
@asoares. Thanks for the solution

@New York. sure, most likely it'll be included in the next release
12 anni tempo fa
I do not understand why you need to modify web.config files :


public abstract class WebViewPage<TModel> : System.Web.Mvc.WebViewPage<TModel>

is already existing in Nop.Web.Framework, you only need to override Lyaout preperty here!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.