Introduction to Epinova Webparts framework for EPiServer CMS

  • 2,073 views
Uploaded on

Held by senior developer Thomas Leela, Epinova at the first EPiServer Oslo Meetup. 26. February 2010.

Held by senior developer Thomas Leela, Epinova at the first EPiServer Oslo Meetup. 26. February 2010.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,073
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
5
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Web Parts in EPiServer [email_address]
  • 2. Introduction
    • Web Parts was launched with ASP.NET 2.0 in 2005.
    • Well established standard.
    • EPiCode.WebParts.Core was originally developed for regjeringen.no by Steve Celius back in 2006.
    • Has over the years evolved and matured into a rich supplement for EPiServer.
    • Web editors applaud the flexibility it offers as is dramatically reduce number of templates and the number of properties on each template.
    • This presentation is actually based on three modules; EPiCode.WebParts.Core, Epinova.WebParts.Providers and Epinova.SpecializedProperties.Flexigrid althought it might have been one big module.
    • Uses none of EPiServers WebPart implementation.
    • Together with DynamicContent the sky is the limit.
  • 3. Dictionary Web Part Controls for creating Web sites that enable end users(editors) to modify the content, appearance, and behavior of Web pages directly in a browser. Zone Container for Web Parts. Dynamic Web Part A Web Part dynamically added by editor. Not to be mistaken with EPiServers dynamic properties nor DynamicContent. Static Web Part A static WebPart or UserControl inside a zone. Much like a UserControl inside a Page. Shared Scope The most commonly used scope in EPiServer context. Editors edit Web Parts which are visible to all users, thus shared. User Scope Fully supported, but rarely used. Provides user personalization capabilities much like igoogle and bbc.co.uk . Web Part Provider Data layer between Web Application and WebPart repository. Flexigrid Free EPiCode module allowing editors to create dynamic Web Part Zones.
  • 4. Demo – Web Part concepts
  • 5.
  • 6. Getting started
    • Include Libraries WebPartsCore Epinova.WebParts.Providers Flexigrid
    • Add language files (optional)
    • Add entry to pages section in Web.config < add tagPrefix =&quot;epicode&quot; tagName =&quot;ManagementConsole&quot; src =&quot;~/Templates/Public/WebParts/Util/ ManagementConsole.ascx &quot;/> < add tagPrefix =&quot;epicode&quot; namespace =&quot;EPiCode.WebParts.EPiChrome&quot; assembly =&quot;EPiCode.WebParts.Core&quot;/>
    • Add ManagementConsole.ascx from WebPartsCore to your project
    • Modify webPart section in Web.config < webParts > < personalization defaultProvider =&quot;EpinovaPageVersionedProvider&quot;> < providers > < clear /> < add name =&quot;EpinovaPageVersionedProvider&quot; type =&quot;Epinova.WebParts.Providers.PageDataPersonalizationProvider&quot; connectionStringName =&quot;EPiServerDB&quot; fallbackProviderName=&quot;&quot; /> </ providers > < authorization > < allow verbs =&quot;enterSharedScope&quot; roles =&quot;WebAdmins, WebEditors, Administrators&quot; /> </ authorization > </ personalization > </ webParts >
  • 7.
    • Add a ScriptManager, WebPartManager and ManagementConsole directly under <form> in MasterPage < form runat =&quot;server&quot;> < asp : ScriptManager runat =&quot;server&quot; EnablePartialRendering =&quot;true&quot; /> < epicode : EpiWebPartManager runat =&quot;server&quot; Personalization-Enabled =&quot;true&quot; Personalization-InitialScope =&quot;Shared&quot; /> < epicode : ManagementConsole runat =&quot;server&quot; />
    • Add Web Part Zones to aspx or ascx < epicode : ZoneLowUiImpact runat =&quot;server&quot; ID =&quot;MainZone&quot; CatalogZoneId =&quot;ThemeCatalogZone&quot; />
    • Add your Web Parts to ManagementConsole.ascx < epicode : WebPartManagementConsole Runat =&quot;server&quot; /> < asp : CatalogZone runat =&quot;server&quot; ID =&quot;ThemeCatalogZone&quot;> < ZoneTemplate > < asp : DeclarativeCatalogPart runat =&quot;server&quot; ID =&quot;ThemeDeclarativeCatalog&quot;> < WebPartsTemplate > < wp : HorizontalRulerPart runat =&quot;server&quot; ID =&quot;HorizontalRulerPart1&quot; /> < wp : BannerPart runat =&quot;server&quot; ID =&quot;BannerPart1&quot; /> </ WebPartsTemplate > </ asp : DeclarativeCatalogPart > </ ZoneTemplate > </ asp : CatalogZone >
    • Inheritance from EPiCode.WebParts.TemplatePageWebPartBase is Obsolete
    • Looks complicated at first glance, but it is quite straightforward!
    • Installer package with examples available at: https://www.coderesort.com/p/epicode/wiki/EPiWebParts
  • 8. Demo –New ZoneLowUiImpact properties
    • ZoneHeaderTemplate and ZoneFooterTemplate defines how the header and footer section of the ZoneLowUiImpact control is displayed. Just like HeaderTemplate and FooterTemplate does so for Repeater control.
    • WebPartHeaderTemplate and WebPartFooterTemplate enables wrapping of Web Parts similar to ItemHeaderTemplate and ItemFooterTemplate in EPiServer.Web.WebControls.PageTree
    • Note the lack of WebPartItemTemplate.
    • < epicode : ZoneLowUiImpact runat =&quot;server&quot; ID =&quot;RightZone&quot; CatalogZoneId =&quot;ThemeCatalogZone&quot; CreateWrapperDiv =&quot;true&quot; > < ZoneHeaderTemplate > < h2 >Zone header</ h2 > < hr /> </ ZoneHeaderTemplate > < ZoneFooterTemplate > < i >End of Zone</ i > </ ZoneFooterTemplate > < WebPartHeaderTemplate > < div class =&quot;box&quot;> < div class =&quot;inner&quot;> </ WebPartHeaderTemplate > < WebPartFooterTemplate > </ div > </ div > < hr /> </ WebPartFooterTemplate > </ epicode : ZoneLowUiImpact >
  • 9. Demo – Think presentation out of the Zone
    • Web Parts appear in different zones with uneven widths and appearance
    • Keep your WebPart markup as simple as possible, hand over styling to container zone.
    • Use <WebPartHeaderTemplate> and <WebPartFooterTemplate> when &quot;boxing&quot; in web parts.
    • < style type =&quot;text/css&quot;>
    • #MainBody .webpart.horizontal { margin-left: 5px; }
    • #MainBody .webpart.horizontal.first, #MainBody .webpart.horizontal.single { margin-left: 0; }
    • #SecondaryBody .webpart { margin-top: 10px; }
    • #SecondaryBody .webpart.first, #SecondaryBody .webpart.single { margin-top: 0; }
    • #SecondaryBody .webpart .box { border-top: solid 6px #ccc; border-left: solid 6px #ccc; }
    • #SecondaryBody .webpart .box img { width: 100%; text-align: center; }
    • #SecondaryBody .webpart .box .inner { border-right: solid 6px #444; border-bottom: solid 6px #444; padding: 3px; }
    • </ style >
  • 10. Demo -Creating a Web Part
    • Remeber to add your WebPart to ManagementConsole.ascx
    • Try to Add DynamicContent into Editor
    • using System;
    • using System.Web.UI;
    • using System.Web.UI.WebControls.WebParts;
    • using EPiCode.WebParts;
    • using EPiServer.Editor;
    • namespace EPiServer.Templates.Public.WebParts
    • {
    • public partial class EditorPart : PropertyDataWebPartBase
    • {
    • [Personalizable, IsRequired, Searchable( true)]
    • public SerializablePropertyXhtmlString Editor{ get; set; }
    • public EditorPart()
    • {
    • Editor = new SerializablePropertyXhtmlString { EditorToolOptions = EditorToolOption.All ^ EditorToolOption.Font };
    • }
    • protected override void OnPreRender( EventArgs e)
    • {
    • var propertyControl = Editor.CreatePropertyControl();
    • propertyControl.PropertyData = new EPiServer.SpecializedProperties. PropertyXhtmlString(Editor.Value as string);
    • Controls.Add(propertyControl as Control);
    • }
    • }
    • }
  • 11. Demo –Static Web Parts
    • Web Parts / UserControls that should occur on most instances of a Page type.
    • Delete is disabled, but Minimize is supported.
    • Great for &quot;template&quot; functionality. < epicode : ZoneLowUiImpact runat =&quot;server&quot; ID =&quot;MainZone&quot; CatalogZoneId =&quot;ThemeCatalogZone&quot; >
    • < ZoneTemplate >
    • < public : MainBody ID =&quot;MainBody1&quot; runat =&quot;server&quot; />
    • < asp : Calendar runat =&quot;server&quot; ID =&quot;Calendar1&quot; />
    • </ ZoneTemplate >
    • </ epicode : ZoneLowUiImpact >
  • 12. Demo -Flexigrid
    • http://www.screencast-o-matic.com/embed?sc=cQ6OQFfSV&w=800&np=0&v=2
  • 13. How to translate Web Part Name
    • Translated in the following order with fallback to class name.
    • Never &quot;Missing translation for….&quot;
    • Automatic and equivalent to page types < webparts > < webpart name =&quot;BannerPart&quot;> < caption >Image banner</ caption > < description >Clickable image banner</ description > </ webpart > </ webparts >
    • WebPartDataLanguageAttribute [ WebPartDataLanguage( &quot;/root/mypath/title&quot;, &quot;/root/mypath/description&quot;)] public partial class BannerPart : UserControlWebPartBase
    • Class name public partial class BannerPart : UserControlWebPartBase
  • 14. Translate Web Part Property Names
    • Translated in the following order with fallback to property name. Never &quot;Missing translation for….&quot;
    • Atomatic and equivalent to page types < webparts > < common > < property name =&quot;Image&quot;> < caption >Select Image</ caption > < help >Select an image from file archive</ help > </ property > </ common > </ webparts >
    • Exsiting PageType Property translation < pagetypes > < common > < property name =&quot;Image&quot;> < caption >Image</ caption > < help > Specify an image that will be shown on the startpage (900*341 pixels) </ help > </ property > </ common > </ pagetypes >
    • PropertyDataLanguageAttribute [ PropertyDataLanguageAttribute( &quot;/mypath/image/name&quot;, &quot;/mypath/image/hoover&quot;)] public PropertyImageUrl Image { get; set; }
    • Property attribute WebDisplayName [ WebDisplayName( &quot;Select Image&quot;), WebDescription( &quot;Select image for the banner property&quot;)] public PropertyImageUrl Image { get; set; }
    • Property Name public PropertyImageUrl Image { get; set; }
  • 15. Web Part and Dynamic Content comparison
    • Very Similar concepts.
    • Complimentary functionality.
    • WebParts with editor can contain DynamicContent
  • 16. Web Parts Dynamic Content Exposes on EPiServer property types X X Preview view X - Soft links (warning on deleting referenced content) X Drag & drop support X - Indexed values (searchable content) X Multilanguage support X X Follow page on copy & paste, export & import X X Editable from View mode (dope) X Can host corresponding Web Part / Dynamic Content X Support IsRequired properties X Resides in WebPartZone PropertyXhtmlString
  • 17. Tips & Tricks
    • Use Web Parts to expose properties from Controls, do not implement logic or presentation.
    • UserControls without parameters can be used directly as web parts eg. asp:Calendar
    • Web Parts might appear in zones with uneven widths and appearance so; Keep your web part markup as simple as possible, hand over styling to containing zone Use <WebPartHeaderTemplate> and <WebPartFooterTemplate> for when &quot;boxing in&quot; web parts
    • Don’t force editors construct repeated web parts on each instance of a page type. -Use static web parts when appropriate.
    • Set default values in constructor when appropriate and Translate both name and Description
    • Use attributes, Searchable and IsRequired (as you do with properties on page types)
    • Handle all Exceptions in a base class for your WebParts. A crashed web part page might be cumbersome to repair.
    • Remember that minimized web parts are not visible.
    • Set &quot;unique per language&quot; as usual in admin.
    • Avoid redundant code. Use your existing Controls directly as WebParts or inside WebParts. Don’t copy!
    • Do your stuff in PreRender as OnLoad is too early when working with Web Parts.
    • Crossbrowser support by using asp.net 4.0 or PreviewVersion
  • 18. A look ahead
    • CMS 6 releases just around the corner.
    • Copy & paste support for web parts.
    • Support for Web Parts stored as Dynamic properties with merge capabilities.
    • More sophisticated access rights
  • 19. References
    • http://labs.episerver.com/en/Blogs/Stein-Viggo-Grenersen/Dates/112262/2/EPiServer-on-steroids/
    • https://www.coderesort.com/p/epicode/wiki/EPiWebParts
    • http://epinova.no/no/Blog/episerver_blog/?BlogBeginDate=2009-10-13
    • http://epinova.no/no/Blog/episerver_blog/?BlogBeginDate=2009-04-14