Close

how to add dynamic content to a topicblock

embryo
12 years ago
#1390 Quote
Avatar
  • 55
Hello-

I'm trying to add a tag cloud to my topic content, but not having any luck.

While editing my content topic in the admin area, I'm just including the following line of code in the table cell where I want the tag cloud to appear:

@Html.Action("PopularProductTags", "Catalog")



Is there something preventing razor syntax from executing when it's dynamically retrieved from a database column? Or do I just need to reference some other assembly from the TopicBlock.cshtml or MegaMenu.cshtml views? If so, which one, and how/where?

Thanks for your assistance!

Steve

IvanStoyanov
12 years ago
#1397 Quote
Avatar
  • 269
embryo wrote:
Hello-

I'm trying to add a tag cloud to my topic content, but not having any luck.

While editing my content topic in the admin area, I'm just including the following line of code in the table cell where I want the tag cloud to appear:

@Html.Action("PopularProductTags", "Catalog")



Is there something preventing razor syntax from executing when it's dynamically retrieved from a database column? Or do I just need to reference some other assembly from the TopicBlock.cshtml or MegaMenu.cshtml views? If so, which one, and how/where?

Thanks for your assistance!

Steve



Hi Steve,

You can not add
@Html.Action("PopularProductTags", "Catalog")

in a topic content, because it is not compiled in razor. If you want to add a tag cloud to the Mega Menu, you need to open the MegaMenu.cshtml view that is located in /Plugins/SevenSpikes.Nop.Plugins.MegaMenu/Views/MegaMenu/.
Once you have opened the view add the following code, on the place where you want the menu to appear:

<li>
<a href="#">@T("Products.Tags.Popular")</a>
@Html.Action("PopularProductTags", "Catalog");
</li>


Have a great day!

Ivan Stoyanov
Thank you for choosing our products! Your feedback is important to us!
embryo
12 years ago
#1402 Quote
Avatar
  • 55
IvanStoyanov wrote:
Hello-

I'm trying to add a tag cloud to my topic content, but not having any luck.

While editing my content topic in the admin area, I'm just including the following line of code in the table cell where I want the tag cloud to appear:

@Html.Action("PopularProductTags", "Catalog")



Is there something preventing razor syntax from executing when it's dynamically retrieved from a database column? Or do I just need to reference some other assembly from the TopicBlock.cshtml or MegaMenu.cshtml views? If so, which one, and how/where?

Thanks for your assistance!

Steve



Hi Steve,

You can not add
@Html.Action("PopularProductTags", "Catalog")

in a topic content, because it is not compiled in razor. If you want to add a tag cloud to the Mega Menu, you need to open the MegaMenu.cshtml view that is located in /Plugins/SevenSpikes.Nop.Plugins.MegaMenu/Views/MegaMenu/.
Once you have opened the view add the following code, on the place where you want the menu to appear:

<li>
<a href="#">@T("Products.Tags.Popular")</a>
@Html.Action("PopularProductTags", "Catalog");
</li>


Have a great day!

Ivan Stoyanov


Hmmm....

That's not quite what I had in mind..I do not want the tag cloud to be a menu item on my megamenu. Rather, I want it as part of the content on my topic page. Is there really no way around this hurdle?

What about this??

Is it possible for me to just create an HTML form with a select field storing all the popular tags as options, and use javascript to change the location (URL) based on the user's selection. This would also need to be inside the content of my topic page. Can javascript be included within a topic page?

If so, and because my site is on IIS, can I also use inline ASP/VBScript in the topic page content to retrieve a recordset of the popular tags and iterate them within my select field?

This will allow me to configure "symptoms" and "conditions" as tags and associate each of my products with the conditions they are useful for treating, or the symptoms that the products help to alleviate.


Thanks,
Steve
Boyko
12 years ago
#1405 Quote
Avatar
  • 1570
embryo wrote:
Hello-

I'm trying to add a tag cloud to my topic content, but not having any luck.

While editing my content topic in the admin area, I'm just including the following line of code in the table cell where I want the tag cloud to appear:

@Html.Action("PopularProductTags", "Catalog")



Is there something preventing razor syntax from executing when it's dynamically retrieved from a database column? Or do I just need to reference some other assembly from the TopicBlock.cshtml or MegaMenu.cshtml views? If so, which one, and how/where?

Thanks for your assistance!

Steve



Hi Steve,

You can not add
@Html.Action("PopularProductTags", "Catalog")

in a topic content, because it is not compiled in razor. If you want to add a tag cloud to the Mega Menu, you need to open the MegaMenu.cshtml view that is located in /Plugins/SevenSpikes.Nop.Plugins.MegaMenu/Views/MegaMenu/.
Once you have opened the view add the following code, on the place where you want the menu to appear:

<li>
<a href="#">@T("Products.Tags.Popular")</a>
@Html.Action("PopularProductTags", "Catalog");
</li>


Have a great day!

Ivan Stoyanov

Hmmm....

That's not quite what I had in mind..I do not want the tag cloud to be a menu item on my megamenu. Rather, I want it as part of the content on my topic page. Is there really no way around this hurdle?

What about this??

Is it possible for me to just create an HTML form with a select field storing all the popular tags as options, and use javascript to change the location (URL) based on the user's selection. This would also need to be inside the content of my topic page. Can javascript be included within a topic page?

If so, and because my site is on IIS, can I also use inline ASP/VBScript in the topic page content to retrieve a recordset of the popular tags and iterate them within my select field?

This will allow me to configure "symptoms" and "conditions" as tags and associate each of my products with the conditions they are useful for treating, or the symptoms that the products help to alleviate.


Thanks,
Steve


Hi Steve,

As Ivan already explained there is no way to add dynamic content within a topic. Topics are stored in the database as a plain text and then they are retrieved from the database when required. They are not compiled at runtime as the Razor views (.cshtml) file. So simply put there is no way around this.
Mixing topic content with some dynamic content could not be achieved without some hacky javascript exercises, which I wouldn't recommend.

Best Regards,
Nop-Templates Support Team
Regards,
Nop-Templates.com Team
embryo
12 years ago
#1406 Quote
Avatar
  • 55
Boyko wrote:

Hi Steve,

As Ivan already explained there is no way to add dynamic content within a topic. Topics are stored in the database as a plain text and then they are retrieved from the database when required. They are not compiled at runtime as the Razor views (.cshtml) file. So simply put there is no way around this.
Mixing topic content with some dynamic content could not be achieved without some hacky javascript exercises, which I wouldn't recommend.

Best Regards,
Nop-Templates Support Team



OK. But I still do not understand completely.

I do now understand that fetching data from the database as the megamenu topic page is loading isn't possible, but I do not understand why having client-side scripting, like javascript, embedded in my topic content wouldn't render and function. Is it just a problem with the encoding?

I'm sorry if I seem obtuse, but I've been programming with ASP for about 14 years and rarely ever find a coding obstacle that cannot be worked-around. I guess I assumed .NET was gonna be even more flexible.

Steve
Boyko
12 years ago
#1413 Quote
Avatar
  • 1570
embryo wrote:

OK. But I still do not understand completely.

I do now understand that fetching data from the database as the megamenu topic page is loading isn't possible, but I do not understand why having client-side scripting, like javascript, embedded in my topic content wouldn't render and function. Is it just a problem with the encoding?

I'm sorry if I seem obtuse, but I've been programming with ASP for about 14 years and rarely ever find a coding obstacle that cannot be worked-around. I guess I assumed .NET was gonna be even more flexible.

Steve


Hi Steve,

To be honest I have't tried adding javascript code into a topic as I have't never needed to something like this. I am just saying that it doesn't seem as a good practice to me. There is a button in the Html editor in the administration that allows you to edit the plain Html , so you can give it a try and see if this would work for you.

Thanks
Regards,
Nop-Templates.com Team