widgetsitefinitysitefinity-10

Call widget directly in template file - Sitefinity


I have created a new widget in the MVC. It is functioning and properly useable in the CMS as expected.

I need to hard-code that directly into the template for another widget, a widgetception if you will. I would like to do this without duplicating the code from my one widget into the other via copy-paste.

I need to do this in the MVC, not using the CMS template editor. Don't ask, it's just an annoying requirement.

I'm more familiar with Wordpress, where you can simply call the shortcode for a plugin and have it render in a template at will. That's the effect I'm trying to accomplish here with Sitefinity for those who know.


Solution

  • So I was way overthinking this. Just grab the partial view:

    @using Telerik.Sitefinity.Blogs.Model
    
    Html.Partial("/Mvc/Views/MyPlugin/index.cshtml").ToString()
    

    Came back to this, it's useful to know that you can also do partials with data passed in:

    Html.Partial("/Mvc/Views/MyPlugin/index.cshtml", new MyModel(){property = value});