Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Widget Library - Is it possible ? View modes: 
User avatar
Member
Member
Ryan - 3/2/2009 7:06:08 PM
   
Widget Library - Is it possible ?
I am trying to make a widget library. This would allow content editors to author and maintain widgets(snippets of html) which are defined in a single place and can then be referenced on multiple pages and inserted into that page at rendertime.

Inline controls are good, but they don't seem to allow content editors to create and manage them.


My solution so far has been to create a folder in my site tree called "SideBarItems" where I have created a number of menuitems - each representing a single widget. This allows the content editors to easily maintain the menuitems as though they were individual widgets.


My main template contains a webpart(derived from CMSAbstractEditableWebPart) that allows the content editors to select any combination of widgets (menuitems) to display on the page. The WebPart saves the documentIDs of the selected widgets in the page custom data. At render time the webpart loads the content from those selected widgets and renders this content into the current page.


This works well when the widgets contain normal html. However when the widget contains an inline control I have no way of processing it.


Ideally i would like to have an editableRegion in my webpart that i can push the content from serveral widgets into and let that render it for me.


Is it possible to manually set the content of an editableRegion in the LoadContent event of a webpart ?

Is it possible to manually render an inlinecontrol ?

Do you have any other suggestions ?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 3/3/2009 6:19:17 AM
   
RE:Widget Library - Is it possible ?
Hello,

The inline controls could be resolved by the API method:

ControlsHelper.ResolveDynamicControls(Panel or Control)


Did you think about the following approach?

The widget would be stored in documents of simple document type. It could contain text, HTML code and/or inline macros.

If the editor likes to use the widget he/she would copy the text (code) from appropriate document and paste it in the Editable region. You could use Editable region type: Text area where is the source code and there may be inline macros, too. If you use Editable region type: HTML Editor you would need to change the mode to Source and then paste the content of widget.

I hope it could help you.

Best regards,
Helena Grulichova

User avatar
Member
Member
Ryan - 3/3/2009 1:30:00 PM
   
RE:Widget Library - Is it possible ?
Hi Helena,

Thanks for the reply, i will try the controlshelper class.

The approach you suggested is workable but doesn't allow the widgets to be managed in a single place, which is what i am trying to achieve - ie changes to a widget are reflected everywhere that widget is used


Could you please tell me whether it is possible to set the content of an editable region manually or is this only done by the pagemanager ?

Regards

Ryan

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 3/4/2009 8:23:09 AM
   
RE:Widget Library - Is it possible ?
Hi Ryan,

you are right with my suggestion.

If you find the source code of Editable text web part (~/CMSWebParts/Text/editabletext.ascx.cs) you could rewrite it. Please see here: http://devnet.kentico.com/docs/devguide/modifying_the_design_of_standa.htm for more information about modifying the code of standard web parts.

You could re-write the “content” variable (for example the line about 547) to change the content of editable region.

Best regards,
Helena Grulichova