overwrite route of the polls

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

from a custom plugin i would like to overwrite the routes of the default polls.
succeeded for the admin side, but cannot do it for the public pages.
Mostly I'm interested for the home page and left column partials.
A bit of help would be nice

for example this didn't worked for the left columns:

var route5 = routes.MapRoute("Plugin.Misc.Polls.CategoryPagePoll",
                "Poll/PollBlock",
                new { controller = "Polls", action = "CategoryPagePoll", area = "" },
                new[] { "Nop.Plugin.Misc.Polls.Controllers" });

            routes.Remove(route5);
            routes.Insert(0, route5);

Thanks!
7 years ago
pop.levente wrote:
Hi All,

from a custom plugin i would like to overwrite the routes of the default polls.
succeeded for the admin side, but cannot do it for the public pages.
Mostly I'm interested for the home page and left column partials.
A bit of help would be nice

for example this didn't worked for the left columns:

var route5 = routes.MapRoute("Plugin.Misc.Polls.CategoryPagePoll",
                "Poll/PollBlock",
                new { controller = "Polls", action = "CategoryPagePoll", area = "" },
                new[] { "Nop.Plugin.Misc.Polls.Controllers" });

            routes.Remove(route5);
            routes.Insert(0, route5);

Thanks!


Which route you want to override ? I think there is no route existing  like "Poll/PollBlock" ..make sure it
7 years ago
could be that there is no route.

i would like to override the Polls partial (controller and action) of the homepage, and of the left side column.
http://docs.nopcommerce.com/display/en/Polls

it's called like
@Html.Action("PollBlock", "Poll", new {systemKeyword = "LeftColumnPoll"})

so probably that is why a route isn't working for me.
is there a way?
7 years ago
pop.levente wrote:
could be that there is no route.

i would like to override the Polls partial (controller and action) of the homepage, and of the left side column.
http://docs.nopcommerce.com/display/en/Polls

it's called like
@Html.Action("PollBlock", "Poll", new {systemKeyword = "LeftColumnPoll"})

so probably that is why a route isn't working for me.
is there a way?


See it is ChildAction ==>

[ChildActionOnly]
        public virtual ActionResult PollBlock(string systemKeyword)
        {
            if (String.IsNullOrWhiteSpace(systemKeyword))
                return Content("");

            var model = _pollModelFactory.PreparePollModelBySystemName(systemKeyword);
            if (model == null)
                return Content("");

            return PartialView(model);
        }


Note: you can write your Action in your plugin then can call directly from views but not it is good way i think.

You can override _pollModelFactory.PreparePollModelBySystemName(systemKeyword) from plugin.
7 years ago
Thanks!.
i have v3.8
what i did is that i have overwritten the GetPollBySystemKeyword from the pollservice.
this did the trick for me.
7 years ago
pop.levente wrote:
Thanks!.
i have v3.8
what i did is that i have overwritten the GetPollBySystemKeyword from the pollservice.
this did the trick for me.


I talked about v3.90
7 years ago
Either way you pointed me to the right direction, so thanks for that! appreciate it. have a nice day!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.