Close

Filters not showing on custom category route

evan@visionfriendly.com
3 months ago
#21262 Quote
Avatar
  • 12
Is there logic inside the widget component to only render if the slug matches a category slug? We have a custom route like "/my-route" that is configured to go to the Category action in the Catalog controller, but with some extra route values as well. When this page is rendered, the filters don't show up, but they work fine on regular category pages. Just wondering if it's because the widget doesn't recognize that it's on a category page. Any ideas to make that work?
Boyko
2 months ago
#21269 Quote
Avatar
  • Moderator
  • 1511
evan@visionfriendly.com wrote:
Is there logic inside the widget component to only render if the slug matches a category slug? We have a custom route like "/my-route" that is configured to go to the Category action in the Catalog controller, but with some extra route values as well. When this page is rendered, the filters don't show up, but they work fine on regular category pages. Just wondering if it's because the widget doesn't recognize that it's on a category page. Any ideas to make that work?


Hi,

We do check for categoryid in the route data so if you don't have it then the Filters will not be shown.
Regards,
Boyko Stanev
Nop-Templates.com
evan@visionfriendly.com
2 months ago
#21271 Quote
Avatar
  • 12
Boyko wrote:
We do check for categoryid in the route data so if you don't have it then the Filters will not be shown.


Hm, categoryId seems to be in the route data in this case. This is what my route looks like...
routeBuilder.MapLocalizedRoute("myroute", "my-route",
                new { controller = "Catalog", action = "Category", categoryId = 26 });

Thoughts?
evan@visionfriendly.com
2 months ago
#21272 Quote
Avatar
  • 12
I should add we're using version 4.2.575.31113 of Nop Ajax Filters for nop 4.20.
Boyko
2 months ago
#21274 Quote
Avatar
  • Moderator
  • 1511
evan@visionfriendly.com wrote:
I should add we're using version 4.2.575.31113 of Nop Ajax Filters for nop 4.20.


Here is how we get the category id:

if (_requestContext.RouteData.Values.Keys.Contains("categoryid"))
            {
                filtersPageParameters.CategoryId = int.Parse(_requestContext.RouteData.Values["categoryid"].ToString());
            }


where _requestContext is Url.ActionContext and Url is a property of the ViewComponent class.

So you can create a widget plugin and make sure it is integrated in one of the supported widget zone i.e left_side_column_before (also make sure you have these widget zones in your custom category page) and you can debug the code to see what could be wrong.
Regards,
Boyko Stanev
Nop-Templates.com
get coupon code