IvanStoyanov wrote:Hi,
I've been trying out Anywhere Slider and it's been working just fine.
I do want to show a slider on a specific Topic page. The documentation does tell me how to create a custom widget zone on a layout, etc. So if I wanted a slider to appear on each Topic page, I could do that.
But is there a way to show a slider on a specific Topic page?
Hi swinstead,
Sadly, nopCommerce does not have the functionality to add script or razor code to topics. To accomplish this you need to modify the
/Views/Topic/TopicBlock.cshtml view.
Find the following code:
<div class="topic-html-content-body">
@Html.Raw(Model.Body)
</div>
and modify it to look like this:
<div class="topic-html-content-body">
@Html.Raw(Model.Body)
@if (Model.SystemName == "YourTopicName")
{
@Html.Widget("custom_widget_zone")
}
</div>
You need to replace
YourTopicName with the system name of the topic, in which you want to add the custom widget zone and
custom_widget_zone with the name of your custom widget zone. You can do this for as many widget zones or topics as you like.
After this follow the documentation on how to add a custom widget zone and add the widget zone to the
SupportedWidgetZones.xml file.
Regards,
Ivan Stoyanov
Hello Ivan-
I followed these instruction to add a custom widget to one of my topic pages and am having much trouble with it. Here is the code I put on the topicblock.cshtml:
<div class="topic-html-content-body">
@Html.Raw(Model.Body)
@if (Model.SystemName == "About")
{
@Html.Widget("aboutemployees_top")
}
</div>
I then added the supported widget zone to the nopAnywhereSliders plugin as described.
It absolutely will not render my widget on the About topic page, but I can adjust my code, for example, to this:
<div class="topic-html-content-body">
@Html.Raw(Model.Body)
@if (Model.SystemName == "HomePageText")
{
@Html.Widget("aboutemployees_top")
}
</div>
...and on the index page of my website, where the HomePageText widget is defined, my custom widget renders just like it should....but not if I switch it back to "About"
I've also tried changing the code to another condition that I know what the result will be (comparing the Title) and it still won't appear...
<div class="topic-html-content-body">
@Html.Raw(Model.Body)
@if (Model.Title == "About Us")
{
@Html.Widget("aboutemployees_top")
}
</div>
(scratching my head.....)
Help??!!??