Close

JCarousel in category of my choice

radoslavy
10 years ago
#7937 Quote
Avatar
  • 10
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?
Deni
10 years ago
#7941 Quote
Avatar
  • Moderator
  • 389
radoslavy wrote:
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?


Hello,

Unfortunately, there is no such functionality in the JCarousel plug-in.

Still, there is something that can be done, but it is not highly recommended:

Lets say you use this widget zone: "categorydetails_top"

Inside the file(check if it is overridden in the theme folder): Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml

find this line:

@Html.Widget("categorydetails_top", Model.Id)


and replace it with these:

@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @Html.Widget("categorydetails_top", Model.Id)
  }
}

Best Regards,
Mladen Staykov
Nop-Templates.com
radoslavy
10 years ago
#7943 Quote
Avatar
  • 10
That works great, but i've got an error when I try to add a second JCarousel with a different widgetzone for the rest of my categories. It works with ELSE command, but that's not what i want because i have more than 2 Jcarousels that i need to insert
radoslavy
10 years ago
#7949 Quote
Avatar
  • 10
I figure it out, I just had to add a new variable :)
Thanks again!
toanhnt
6 years ago
#14906 Quote
Avatar
  • 35
Deni wrote:
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?

Hello,

Unfortunately, there is no such functionality in the JCarousel plug-in.

Still, there is something that can be done, but it is not highly recommended:

Lets say you use this widget zone: "categorydetails_top"

Inside the file(check if it is overridden in the theme folder): Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml

find this line:

@Html.Widget("categorydetails_top", Model.Id)


and replace it with these:

@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @Html.Widget("categorydetails_top", Model.Id)
  }
}



Hi, how to achieve this with new version nop4.0? Thanks
Valentin
6 years ago
#14907 Quote
Avatar
  • 172
toanhnt wrote:
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?

Hello,

Unfortunately, there is no such functionality in the JCarousel plug-in.

Still, there is something that can be done, but it is not highly recommended:

Lets say you use this widget zone: "categorydetails_top"

Inside the file(check if it is overridden in the theme folder): Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml

find this line:

@Html.Widget("categorydetails_top", Model.Id)


and replace it with these:

@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @Html.Widget("categorydetails_top", Model.Id)
  }
}



Hi, how to achieve this with new version nop4.0? Thanks



Hello toanhnt,

in order for the code, you already have to work in version 4.0 you need to replace this line of code:

@Html.Widget("categorydetails_top", Model.Id)


with this line of code:

@await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })

Leave the rest the same and everything should work normally.
Best Regards,

Valentin Kirov
Nop-Templates.com
toanhnt
6 years ago
#14910 Quote
Avatar
  • 35
Valentin wrote:
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?

Hello,

Unfortunately, there is no such functionality in the JCarousel plug-in.

Still, there is something that can be done, but it is not highly recommended:

Lets say you use this widget zone: "categorydetails_top"

Inside the file(check if it is overridden in the theme folder): Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml

find this line:

@Html.Widget("categorydetails_top", Model.Id)


and replace it with these:

@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @Html.Widget("categorydetails_top", Model.Id)
  }
}



Hi, how to achieve this with new version nop4.0? Thanks


Hello toanhnt,

in order for the code, you already have to work in version 4.0 you need to replace this line of code:

@Html.Widget("categorydetails_top", Model.Id)


with this line of code:

@await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })

Leave the rest the same and everything should work normally.


Thanks, it works great. One last question. How to add 2 widget zones or more with the same method ablove?
Valentin
5 years ago
#14930 Quote
Avatar
  • 172
toanhnt wrote:
Hello guys,
Is there a way that I can show my Jcarousel products in category of my choice ?

Hello,

Unfortunately, there is no such functionality in the JCarousel plug-in.

Still, there is something that can be done, but it is not highly recommended:

Lets say you use this widget zone: "categorydetails_top"

Inside the file(check if it is overridden in the theme folder): Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml

find this line:

@Html.Widget("categorydetails_top", Model.Id)


and replace it with these:

@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @Html.Widget("categorydetails_top", Model.Id)
  }
}



Hi, how to achieve this with new version nop4.0? Thanks


Hello toanhnt,

in order for the code, you already have to work in version 4.0 you need to replace this line of code:

@Html.Widget("categorydetails_top", Model.Id)


with this line of code:

@await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })

Leave the rest the same and everything should work normally.

Thanks, it works great. One last question. How to add 2 widget zones or more with the same method ablove?


Hello again toanhnt,

to achieve this, use the same line of code but change the name to the widget you want to use and add it underneath, like so:


@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })
    @await Component.InvokeAsync("Widget", new { widgetZone = "NAME_OF_OTHER_WIDGET_ZONE", additionalData = Model.Id })
  }
}


That is if you want to show them one after another, or if you want it on a different location you can call it separately like so:


@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @await Component.InvokeAsync("Widget", new { widgetZone = "NAME_OF_OTHER_WIDGET_ZONE", additionalData = Model.Id })
  }
}


Just have in mind that you can use the already existing widget zones for this to work.

Hope this was helpful.
Best Regards,

Valentin Kirov
Nop-Templates.com
toanhnt
5 years ago
#14931 Quote
Avatar
  • 35
Hello Valentin Kirov,

Thank you for your reply. What I mean is
how to add another widget zone under that but using different category ID for the new widget zone.
For example:

var categoryIds = new List<int> { 2, 3, 4 }
widgetZone = "categorydetails_top"
var categoryIds = new List<int> { 5, 6, 7 }
widgetZone = "example"
Valentin
5 years ago
#14936 Quote
Avatar
  • 172
toanhnt wrote:
Hello Valentin Kirov,

Thank you for your reply. What I mean is
how to add another widget zone under that but using different category ID for the new widget zone.
For example:

var categoryIds = new List<int> { 2, 3, 4 }
widgetZone = "categorydetails_top"
var categoryIds = new List<int> { 5, 6, 7 }
widgetZone = "example"


Hello again toanhnt,

in that case you should do something like this:




@{
  var categoryIds = new List<int> { 2, 3, 4 }; // Inside the curly brackets you can list all category IDs, comma separated

  if (categoryIds.Contains(Model.Id))
  {
    @await Component.InvokeAsync("Widget", new { widgetZone = "categorydetails_top", additionalData = Model.Id })
  }
}

@{
  var secondCategoryIds = new List<int> { 5, 6, 7 }; // Inside the curly brackets you can list all category IDs for the additional widget-zone, comma separated

  if (secondCategoryIds.Contains(Model.Id))
  {
    @await Component.InvokeAsync("Widget", new { widgetZone = "NAME_OF_OTHER_WIDGET_ZONE", additionalData = Model.Id })
  }
}



Where for the secondCategoryIds you specify only the IDs for the additional widget zone.
Best Regards,

Valentin Kirov
Nop-Templates.com