How to add custom widgets on .NET Core Renderer? are there any latest docs that i can refer to ensure it works fine?

I have tried to follow this link: Create a custom ASP.NET Core widget - Sitefinity CMS Frontend development

the difference is only on the named folder Models instead of Entities. Building got no issues, but when i checked inside the page editor it doesnt appear. Also i was wondering why does for layout the list is not the same inside the toolboxes from the settings? What is the way for me to fix these issues?

Currently im using trial version of 15.3.8522 for my CMS backend.

imageThank you for the help


Sabrie Nedzhip likes this.
  • Sabrie Nedzhip (Enso DX)

    Hi @Adam Idris Mohamad Ismol (Customer)​ ,

     

    The Content block and the Rich text editor fields are stripping out javascript code by default.

     

    Recently we also had to enable and whitelist some tags in the .NET Core app for a project.

     

    The first thing you need to do is to set the scripts serialization property of the Kendo editor to "true" (the Content block and Rich text editor fields are using Kendo rich text editor). To do that:

     

    1. Go to Administration -> Settings
    2. Backend interface
    3. Expand the Rich text editor
    4. Find "serialization" property in the json and set its "scripts" property to true
    5. Save changes
    1. "serialization":{
    2. "semantic":true,
    3. "scripts": true
    4. },

    image 

    You may also need to whitelist the tags or their attributes. For this you need to extend the HtmlSanitizer. This documentation article describes it really well: https://www.progress.com/documentation/sitefinity-cms/html-sanitization

     

    In our case we had to enable the script tag:

     

    1. public SitefinityExtendedHtmlSanitizer()
    2. : base()
    3. {
    4. this.AllowedTags.Add("script");
    5. }

    You need to do this both in the Sitefinity CMS standard project and in the .NET Core app.

     

    This should whitelist the tags or attributes that you define and they will not be stripper.

     

    You can also disable HtmlSanitization - which is not recommended of course.

    But you can do it under Administration - Advanced -Security

     

    image 

    Let me know if it works. If you still have issues you need to provide more details with a sample so I can try it on my side.

     

    Regards,

    Sabrie

    Selected as Best
  • Sabrie Nedzhip (Enso DX)

    Hi @Adam Idris Mohamad Ismol (Customer)​ ,

     

    Is it possible that you access the Sitefinity website through the standard Sitefinity CMS and not through the Sitefinity .NET Core? This might explain why you don't see the widget in the backend when you edit a page.

     

    I took a screenshot from the backend of my page editing screen on the .NET Core webapp:

     

    imageimage 

    When I click Add widget I get the toolbox on the right side with the Content and Layout widgets registered in Sitefinity. One of the screenshot shows the Content tab and the content widgets that are registered in Sitefinity. And the second screenshot shows the Layout tab where you see the section widget. You say that you have some issues there as well but I didn't understand what the issue is.

     

    When you edit a page and try to add a widget on your side do you get that same toolbox or it looks different? It would be great if you take a screenshot on your side.

     

    In addition to that, I would suggest you keep entity files inside Entities folder.

     

    You can take a look at the Hello World widget sample published on the Sitefinity github account: https://github.com/Sitefinity/sitefinity-aspnetcore-mvc-samples/tree/master/src/hello-world

     

    If you follow the sample the widget will correctly register in Sitefinity and you will be able to use it when you edit pages in your Sitefinity .Net Core website?

     

    Let me know how it goes and if you still have issues and I will help further. Please provide more details and screenshots - it will help better understand what the issue could be.

     

    Regards,

    Sabrie

  • Hi Sabrie,

     

    Yes, true i just found out after i post this question. Thank you for the clarification and sharing much appreciated. I managed to do more after i discover the new editor.

     

    I'll keep in mind on your suggestion during my learning for the development.

     

    Thanks again.

     

    Warm Regards,

    Adam Idris

  • Sabrie Nedzhip (Enso DX)

    Hi Adam Idris,

     

    I am glad to hear you figured it out and thanks for following up in the post 😊

     

    If you have any other questions, please feel free to start a new thread and make sure to add it under "Sitefinity .NET Core" or "Sitefinity General Discussions" or another relevant topic category depending on your questions. This will make sure your question reaches the right people (the Sitefinity people) and increases the chances of getting help and replies.

     

    The current thread is in the "Community Corner" and it might not be visible to Sitefinity community users who can assist you with Sitefinity tech questions.

     

    Happy coding and I hope you are enjoying your experience with Sitefinity .NET Core.

     

    Regards,

    Sabrie

  • Hi Sabrie,

     

    I have a follow up question regarding the new page editor.

     

    So basically, I'm currently explore on capabilities of each widget, I found that the content block widget can customized using code.

     

    But the problem I interfere currently is that script and style tag from my code is not able to save in the code view, only iframe tag. The script and style tag contain the url where the object inside iframe tag will be retrieved, so may I know is there a way I can make this work as expected?

     

    Warm Regards,

    Adam Idris

    • Sabrie Nedzhip (Enso DX)

      Hi @Adam Idris Mohamad Ismol (Customer)​ ,

       

      The Content block and the Rich text editor fields are stripping out javascript code by default.

       

      Recently we also had to enable and whitelist some tags in the .NET Core app for a project.

       

      The first thing you need to do is to set the scripts serialization property of the Kendo editor to "true" (the Content block and Rich text editor fields are using Kendo rich text editor). To do that:

       

      1. Go to Administration -> Settings
      2. Backend interface
      3. Expand the Rich text editor
      4. Find "serialization" property in the json and set its "scripts" property to true
      5. Save changes
      1. "serialization":{
      2. "semantic":true,
      3. "scripts": true
      4. },

      image 

      You may also need to whitelist the tags or their attributes. For this you need to extend the HtmlSanitizer. This documentation article describes it really well: https://www.progress.com/documentation/sitefinity-cms/html-sanitization

       

      In our case we had to enable the script tag:

       

      1. public SitefinityExtendedHtmlSanitizer()
      2. : base()
      3. {
      4. this.AllowedTags.Add("script");
      5. }

      You need to do this both in the Sitefinity CMS standard project and in the .NET Core app.

       

      This should whitelist the tags or attributes that you define and they will not be stripper.

       

      You can also disable HtmlSanitization - which is not recommended of course.

      But you can do it under Administration - Advanced -Security

       

      image 

      Let me know if it works. If you still have issues you need to provide more details with a sample so I can try it on my side.

       

      Regards,

      Sabrie

      Selected as Best