Lee Crowe
Oct 25, 2010
  7181
(5 votes)

EPiServer Search and Replace Plug-in Released

A couple of months ago myself and a couple of my colleagues were discussing features that are currently missing from EPiServer CMS.  One feature clients often request is a global search and replace feature.

After the discussion I thought this sounded like an interesting task, so I decided I would attempt to create a plug-in to do this.  Several weeks later after building the plug-in during my commute to and from work it is available for everybody to use Smile.  Hooray you all cry!

The plug-in will work in EPiServer CMS 6 and later and will search and replace both page type and dynamic properties. 

The plug-in is careful in what it updates and will not mess with XHTML/serialized XML structures.  A regex is used to determine whether the content is xml or not and if it is only attribute values and text nodes are updated.

The plug-in currently does not search and replace dynamic content, it’s something I have looked into but could open a big can of worms so I have left it for now.

To install it is as simple as copying an assembly to your bin folder and adding some configuration settings to your web.config.

Please feel free to download the plug-in and give it a try.  All feedback, suggested enhancements will be greatly received… Apart from negative feed back Winking smile.

The assemblies and source code if required can be found here http://episerversap.codeplex.com/

Installation/Usage instructions can be found here.

Oct 25, 2010

Comments

Deane Barker
Deane Barker Oct 25, 2010 05:24 PM

How are you ensuring they don't replace text not in a tag, for HTML properties? For instance, if someone replaces "table" with "chair," how do you make sure they don't replace all the TABLE tags too?

Oct 25, 2010 06:08 PM

Hi Deane

The search and replace code determines whether the text is xhtml/xml and if it is it uses an Sgml reader to parse the html into a document.

The code then selects all nodes in the document '//*' and then iterates through each of them.

For each node it then gets the text nodes 'text()' and updates the text values and then iterates the attributes and updates there values. This ensures there is no risk of harming the tags :)

Lee

Oct 25, 2010 06:18 PM

This is excellent Lee, looking forward to trying it out.

Janne Tuutti
Janne Tuutti May 16, 2013 02:20 PM

Hi Lee,

I am currently trying to get this working but have run against error on after logging to CMS edit mode:


Compiler Error Message: CS0118: 'FortuneCookie.EPiServer.SearchAndReplace.SearchAndReplacePlugin.List()' is a 'method' but is used like a 'type'

Source Error:


Line 215: <%#server.htmlencode(eval("find").tostring())%>
Line 216: <%#server.htmlencode(eval("replace").tostring())%>
Line 217: <%#((list>)Eval("Pages")).Count%>
Line 218: <%#((list>)Eval("DynamicProperties")).Count%>
Line 219: <%#((datetime)eval("created")).tostring("dd mm yyyy hh:mm:ss")%>


Source File: /Templates/Plugins/SearchAndReplace.ascx Line: 217


My solution is built with Visual Studio 2008 and .Net Framework 3.5 and am trying to run the SearchAndReplace against EPiServer 6 site. I've extracted the dll's and configs from NugetPkg with VS2010 and added them by hand in my VS2008 solution. Is there any hope for me to get it working they way I'm attempting?

Thanks in advance,
Janne


Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024