Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Update all widget instances View modes: 
User avatar
Member
Member
jwynveen - 10/11/2013 4:25:50 PM
   
Update all widget instances
Is there a way to use widgets as basically shared blocks of code that could be put on multiple pages and be updated centrally via that widget's properties?

Example: I want to have a configurable sidebar on pages throughout the site. I'd like to create a set of widgets that content editors are able to put on whatever pages they want in widget zones that I would set up. I would ideally set these up as static text or HTML which the editors would not be able to modify, and whenever I needed to change some copy/style in that widget, I could do so through that widget's definition and it would update all instances of that widget.

I tried doing this by creating a widget using the Static HTML web part and setting the default value for the Text property to the HTML I want it to use. I then added it to a page both in a widget zone and inline in an editable HTML region. When I went back to the widget and changed some of the text I saw the change reflected in the inline widget but not the one in the widget zone. How could I set this up so that both would be updated like the inline widget was?

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 10/12/2013 3:24:54 AM
   
RE:Update all widget instances
Hi John,

Thank your message.

The only way of doing this would be that the other widgets would be pointing to the same instance of the widget and I dont think this is easily possible.

What comes to my mind is that if you would develop a custom widget (based on some our) and then change its code behind and set all the properties yourself (meaning that you would not allow to set those properties. This would mean that all widgets of selected type would be basically the same. I hope that its understandable.

Let me know if you need anything else.

Kind regards,
Richard Sustek

User avatar
Member
Member
jwynveen - 10/14/2013 9:06:47 AM
   
RE:Update all widget instances
Is there a way instead to create a widget that displays an item from a custom table or custom document type? I could then keep the content centralized in one of those tables and have a widget that would allow the user to select which of the content items should display in the widget. Is there any widget/web part that does this already? Or would I need to build something to do so?

Or I suppose a similar option could be as follows. Create a custom document type. In the root of the site, create a folder that would contain all of the items of that new doc type. This would be the central repository for the side bar content. To add to a page, I could add linked docs to them under the page they should appear. I could then use a repeater to display all child documents of that type in the side bar (I set up something similar last week for a rotating carousel). Would this be a good way to set this up?

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 10/15/2013 3:33:00 AM
   
RE:Update all widget instances
Hi,

I think this could work, but would require some custom coding as there is not such build webpart to support this.

The steps you could do are following:

Go to Site manager -> Development -> Widgets and find the widget you want to use. Then check what webpart is the widget based on. Now you have to clone the webpart and modify its code that you would set the properties yourself directly in the code (you can get it out of the document type with no problem, I can guide you through getting the data if you need) and then you would create a widget out of the modified webpart and now you have it :-)

Do you have any further questions?

Kind regards,
Richard Sustek