Close

Place slider on specific Topic page

swinstead
11 years ago
#2294 Quote
Avatar
  • 6
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?

IvanStoyanov
11 years ago
#2296 Quote
Avatar
  • 269
swinstead 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
Thank you for choosing our products! Your feedback is important to us!
swinstead
11 years ago
#2298 Quote
Avatar
  • 6
That's a perfectly fine solution for me. Thank you!
joster
11 years ago
#3773 Quote
Avatar
  • 130
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??!!??
Support
11 years ago
#3804 Quote
Avatar
  • Moderator
  • 1044
Hi joster,

I think you have written the system name for the About Us topic incorrect. Can you try with the following:

<div class="topic-html-content-body">
    @Html.Raw(Model.Body)
    @if (Model.SystemName == "aboutus")
    {
        @Html.Widget("aboutemployees_top")
    }
</div>


Looking forward to your reply!
MARIAAPOSTOLAKI
10 years ago
#4192 Quote
Avatar
  • 1
Hello,

I have created one page with the system name "wherearewe" that displays some info about the place where my shop is.

I have created at the "SupportedWidgetZones.xml" file a new widget zone with the name "slider_zone" and at the "TopicBlock.cshtml" I have changed the code:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
        </div>
into:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
            @if (Model.SystemName == "WhereAreWe")
            {
                @Html.Widget("slider_zone")
            }
        </div>

Although I have done all the above, the slider isn't displayed.

Can anyone help me please?!?!

P.S. I am using NopCommerce 3.10
Support
10 years ago
#4197 Quote
Avatar
  • Moderator
  • 1044
MARIAAPOSTOLAKI wrote:
Hello,

I have created one page with the system name "wherearewe" that displays some info about the place where my shop is.

I have created at the "SupportedWidgetZones.xml" file a new widget zone with the name "slider_zone" and at the "TopicBlock.cshtml" I have changed the code:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
        </div>
into:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
            @if (Model.SystemName == "WhereAreWe")
            {
                @Html.Widget("slider_zone")
            }
        </div>

Although I have done all the above, the slider isn't displayed.

Can anyone help me please?!?!

P.S. I am using NopCommerce 3.10


Hi MARIAAPOSTOLAKI,

Can you please use the same system name in the view as it is shown in the administration, i.e. wherearewe lowercase. As you are making the compare with "==" it is case sensitive. Also have you mapped the slider to the "slider_zone" widget zone in the administration of the slider.

Best Regards!
AnGeLSpiRiT
10 years ago
#4497 Quote
Avatar
  • 2
Support wrote:
Hello,

I have created one page with the system name "wherearewe" that displays some info about the place where my shop is.

I have created at the "SupportedWidgetZones.xml" file a new widget zone with the name "slider_zone" and at the "TopicBlock.cshtml" I have changed the code:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
        </div>
into:
        <div class="topic-html-content-body">
            @Html.Raw(Model.Body)
            @if (Model.SystemName == "WhereAreWe")
            {
                @Html.Widget("slider_zone")
            }
        </div>

Although I have done all the above, the slider isn't displayed.

Can anyone help me please?!?!

P.S. I am using NopCommerce 3.10

Hi MARIAAPOSTOLAKI,

Can you please use the same system name in the view as it is shown in the administration, i.e. wherearewe lowercase. As you are making the compare with "==" it is case sensitive. Also have you mapped the slider to the "slider_zone" widget zone in the administration of the slider.

Best Regards!


Hi!
I have done exactly the same as MARIAAPOSTOLAKI with the the same system name in the view as it is shown in the administration and i have choosen the right zone at the widget zone in the administration of the slider. But still nothing..! :( The slider isn't displayed.. Can you help me please!!!

Thx,
Boyko
10 years ago
#4498 Quote
Avatar
  • 1570
AnGeLSpiRiT wrote:

Hi!
I have done exactly the same as MARIAAPOSTOLAKI with the the same system name in the view as it is shown in the administration and i have choosen the right zone at the widget zone in the administration of the slider. But still nothing..! :( The slider isn't displayed.. Can you help me please!!!

Thx,


Hi AnGeLSpiRiT,

Please make sure the Slider isn't mapped to a category or a manufacturer as otherwise it won't show on any other pages i.e topic pages.

Thanks
Regards,
Nop-Templates.com Team
AnGeLSpiRiT
10 years ago
#4539 Quote
Avatar
  • 2
Boyko wrote:

Hi!
I have done exactly the same as MARIAAPOSTOLAKI with the the same system name in the view as it is shown in the administration and i have choosen the right zone at the widget zone in the administration of the slider. But still nothing..! :( The slider isn't displayed.. Can you help me please!!!

Thx,

Hi AnGeLSpiRiT,

Please make sure the Slider isn't mapped to a category or a manufacturer as otherwise it won't show on any other pages i.e topic pages.

Thanks


Hi!

I would like to inform you that the slider isn't mappad to a category or a manufacturer.. Could you please think some other reason or solution?

Thx,