Introducing Page Type Builder UI
Back in November 2010 Erik Nordin released his PropertyMatch.aspx admin plug-in for PageTypeBuilder see the article here.
This little tool has been invaluable for anybody using PageTypeBuilder on large EPiServer builds. It points out discrepancies between PageTypeBuilder page type properties and EPiServer page type definitions and allows you to edit or remove them.
For the last few weeks I have been helping Joel Abrahamsson out adding various features to the up and coming version of PageTypeBuilder.
Over the last week I have had a bit of unoccupied train commuting time so I decided to revisit the plug-in that Erik originally created and extend it a little as there were a few things I thought were missing.
Note to Erik: Sorry Erik, I’m not trying to steal your thunder here but thought the new additions described below are very useful and for the greater good of the community .
Installation
To install the plug-in you will need to download the relevant version of the PageTypeBuilderUI.dll from codeplex and add it to your EPiServer CMS 6 projects bin folder.
The version numbers of the releases are currently inline with the relevant version of PageTypeBuilder they are built against.
Current versions are:
- v1.3
- v1.3.1
- v1.9.1 (PageTypeBuilder v2 Preview 1)
- v1.9.2 (PageTypeBuilder v2 Preview 2)
You will also need to add the following folder to your web app /Templates/Plugins/Admin.
You may well be wondering why the project is named PageTypeBuilderUI rather than PageTypeBuilder.UI? This is because in time this project may be integrated into PageTypeBuilder v2+ so we wouldn’t want naming conflicts
Please note: The plugin is built to work with EPiServer CMS 6 R1 and upwards and PTB v1.3 and upwards.
It is advised you lock the plug-in down to WebAdmins and Administrators. To do this you can add the following to your web.config:
1: <location path="Templates/Plugins/Admin">2: <system.web>3: <authorization>4: <allow roles="WebAdmins, Administrators"/>5: <deny users="*"/>6: </authorization>7: </system.web>8: </location>
New Features
- Updating of property types
I believe Erik had previously mentioned that he would like to add this functionality assuming he got time but probably never got around to it.
If there are discrepancies between the EPiServer page definition type and the PageTypeBuilder page type property type then a checkbox will be displayed which can be checked to indicate that you would like the type to be updated. When the ‘Update Property Types’ button is clicked the page definitions will be updated with the PageTypeBuilder Page Type property type. A suitable warning about potential loss of data will be displayed first.
When updating property types, if a default value has been specified that is not valid for the new type a suitable error message will be displayed and the property will not be updated. This is inline with the validation which is performed in EditPageTypeField.aspx - Bulk removal of properties
If there are any properties to be removed you can select all relevant page definitions by either checking the ‘Remove’ check boxes individually or toggling the select all check box. Upon clicking the ‘Remove Properties’ button all selected page definitions will be deleted. - Bulk update of property types
If there are any properties that need there property types updating you can select all the relevant page definitions by either checking the ‘Update Type’ check boxes individually or toggling the select all check box. Upon clicking the ‘Update Property Types’ button all selected page definitions will have there types updated. - If ‘Show only miss-matches is checked then only page types with mismatches will be shown
Below is a screen dump of the admin plug-in:
Globalizing the plug-in
The text displayed by the plug-in is taken from an embedded resource of the PageTypeBuilderUI.dll assembly. If you would like to globalize the plug-in you can add the language settings found here into the relevant language file within your EPiServer site.
Future versions
When PageTypeBuilder v2.0 is officially released I will release PageTypeBuilderUI v2.0.
Feedback
Please feel free to email or twitter me with any feedback @croweman
Great work Lee! And you don't have to worry about me being offended. :)
Thanks Erik :v)
For those of you unfortunate ones who have already downloaded the plug-in, I noticed a spelling mistake and had also placed the virtual page path within the /templates folder. This would mean you can not easily secure the page.
All of the available packages on codeplex have been updated to fix the spelling mistake and page path issue.
Sorry for any inconvenience.
Lee
Great work Lee. I too found the previous version always had a mismatch with XHTMLStrings and PropertyStrings (or something along those lines) and I had to manually update the type on the PTB class. Updating it was something on my to-do list, so you saved me a job!
(Edit: Just realised the mismatch with string types is in the CreatePTBClasses plugin, not the MatchPTBProperties discussed here! Ooops!)
One thing worth noting, I'd included the source as a project in one of our solutions, and was encountering the issue described in http://support.microsoft.com/kb/957661
I had to change the target framework on the project to .net 4, but it still complained that the /Templates/Plugins/Admin/ folder didn't exist. The quick fix is obviously to create the folder, (or change the plugin Url) but it might be worth considering overriding the GetDirectory method in the ResourcePathProvider to make this a fully contained 'drop and go' plugin.
I forgot to test for the /Templates/Plugins/Admin folder not existing. That's what happens when you release things when you are half asleep :)
I will update at some point.
Hi Lee,
I hope you can help me, I keep getting this error when I try to open the page.
Directory 'C:\Users\gerg\Documents\Projects\_svn\_EpiServer\deploeg\branches\bugfixing\2.2\Indivirtual.DePloeg.Web\Templates\Plugins\Admin' does not exist. Failed to start monitoring file changes.
Is there something else that needs configuration?
Hi Ger
The version of PageTypeBuilderUI you are using is dependent on the web application containing the following folder heirarch /Templates/Plugins/Admin.
This issue has been resolved in the latest version of PageTypeBuilderUI which can be downloaded from codeplex or the nuget episerver feed.
Lee
Too bad, still can't get it to work, even with the latest PageBuilderUI version (1.9.2) and the latest Episerver version (6.1.379.0).
Also tried it in the example site (Alloy Technologies), but there I get the same error!
What version of PTB are you using? And also has the error changed? If you are using the latest version the plugin will be pulled from the /Util/ path and not /Templates/.
PTB version is 1.3.1.0. The error is still the same. I'm using the http://pagetypebuilderui.codeplex.com/releases/view/70719#DownloadId=263289 version.
You will need PageTypeBuilderUI v1.3.1 for PTB v1.3.1. PageTypeBuilderUI v1.9.2 is for PTB v2 Preview 2.
Hope that helps?
Hi Lee, thanks but still no success. I've now tried PTB UI 1.3.1 but the same error keeps popping up.
Small piece of the stack trace:
[HttpException (0x80070003): Directory 'C:\Users\gerg\Documents\Projects\_svn\_EpiServer\deploeg\branches\bugfixing\2.2\Indivirtual.DePloeg.Web\Templates\Plugins\Admin' does not exist. Failed to start monitoring file changes.]
System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError) +827
System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback, FileAttributesData& fad) +1063
System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) +11559984
System.Web.Caching.CacheDependency..ctor(Int32 dummy, String[] filenames, DateTime utcStart) +63
We will get there in the end. I have just checked the assembly on codeplex and it was still using /Templates directory rather than /util. The nuget package is up to date but codeplex wasn't but is now.
If you dry downloading again you should be sorted? Sorry for messing you around.
yes! It's working now. Thanks Lee.
This one is kind of restrictive if you use another role provider than the one shipped with EPiServer (ex. AD or a custom)
if (!this.User.IsInRole("WebAdmins") && !this.User.IsInRole("Administrators"))
this.Response.Redirect("/", true);
Guess I have to download the source :D
Yes it is, I did think about making the role configurable but never got round to doing it :(
any chance of an EPiServer 7 port?