<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Andreas Ek</title><link href="http://world.optimizely.com" /><updated>2009-03-25T17:26:00.0000000Z</updated><id>https://world.optimizely.com/blogs/Andreas-Ek/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>jQuery and ajax page tree service</title><link href="https://world.optimizely.com/blogs/Andreas-Ek/Dates/2009/3/jQuery-and-ajax-page-tree-service/" /><id>&lt;p&gt;I needed to show the pagetree for my users and tried out several dynamic ajax based and jquery based treeviews. I liked the “dynatree” best and I want to share a simple implementation. In this case I will place the control in the public presentation. Perhaps it is more suitable to use it in a edit or admin plugin with EPiServer.&lt;/p&gt;  &lt;p&gt;The code mirrors the pagetree in EPiServer and shows selected pages in a result div.&lt;/p&gt;  &lt;p&gt;The pagetree is loaded “lazy” and requests are made via json produced by a simple aspx page.&lt;/p&gt;  &lt;p&gt;&lt;a href=&quot;/link/2afa7a14de95480e8fa0da7a2ba82de1.png&quot; target=&quot;_blank&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;415&quot; alt=&quot;image&quot; src=&quot;/link/803c6e26d46e4226885b7755f8441365.png&quot; width=&quot;644&quot; border=&quot;0&quot; /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;JQuery files&lt;/h3&gt;  &lt;p&gt;These are the jQuery-files I added to get this to work. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;jQuery 1.3.2 (core jQuery)&lt;/li&gt;    &lt;li&gt;jQuery UI, 1.7 (user interface)&lt;/li&gt;    &lt;li&gt;jquery.dynatree.js (the main treeview js)&lt;/li&gt;    &lt;li&gt;jquery.cookies.js (to get peristance)&lt;/li&gt;    &lt;li&gt;Skin to the dynatree included in the demo.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jqueryTree/Templates/Scripts/jquery-1.3.2.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;   &lt;br /&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jqueryTree/Templates/Scripts/jquery-ui-1.7.custom.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;    &lt;br /&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jqueryTree/Templates/Scripts/jquery.cookie.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;    &lt;br /&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jqueryTree/Templates/Scripts/jquery.dynatree.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &lt;/p&gt;  &lt;p&gt;&amp;lt;link type=&amp;quot;text/css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; href=&amp;quot;/jqueryTree/Templates/Styles/ui-lightness/jquery-ui-1.7.custom.css&amp;quot; /&amp;gt;   &lt;br /&gt;&amp;lt;link type=&amp;quot;text/css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; href=&amp;quot;/jqueryTree/Templates/Styles/jqueryTree.css&amp;quot; /&amp;gt;    &lt;br /&gt;&amp;lt;link type=&amp;quot;text/css&amp;quot; rel=&amp;quot;Stylesheet&amp;quot; href=&amp;quot;/jqueryTree/Templates/Styles/DynaTreeSkin/ui.dynatree.css&amp;quot; /&amp;gt; &lt;/p&gt;  &lt;h3&gt;&amp;#160;&lt;/h3&gt;  &lt;h3&gt;JQuery to start the tree&lt;/h3&gt;  &lt;p&gt;Then there is a declaration to get the tree to work against a “div” in the usercontrol.&lt;/p&gt;  &lt;p&gt;$(document).ready(function() { &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; $(document).find(&#39;#tree&#39;).dynatree({   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; title: &amp;quot;Root folder&amp;quot;,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; rootVisible: true,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; autoFocus: false,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; persist: true,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; fx: { height: &amp;quot;toggle&amp;quot;, duration: 200 },    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initAjax: {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; url: &amp;quot;/jqueryTree/Templates/Service/jqueryTree.aspx&amp;quot;,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data: { key: &amp;quot;root&amp;quot; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; },    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; onActivate: function(dtnode) {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(document).find(&#39;#result&#39;).append(dtnode.data.title + &#39; (Page ID: &#39; + dtnode.data.key + &#39;)&amp;lt;br /&amp;gt;&#39;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; $(document).find(&#39;#result&#39;).effect(&#39;pulsate&#39;);    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; },    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; onLazyRead: function(dtnode) {    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dtnode.appendAjax(    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; { url: &amp;quot;/jqueryTree/Templates/Service/jqueryTree.aspx&amp;quot;,    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; data: { key: dtnode.data.key }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; });    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; });    &lt;br /&gt;}); &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h3&gt;JSON service&lt;/h3&gt;  &lt;p&gt;As you can see the function calls the service to get the children. The first time it will get the page root and then for each page it would get the children.&lt;/p&gt;  &lt;p&gt;The service is a clean and simple aspx page that gives the json result like this example:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;[ &lt;/p&gt;    &lt;p&gt;{ title: &#39;Recycle Bin&#39;,isLazy: false,key: &#39;2&#39;} , &lt;/p&gt;    &lt;p&gt;{ title: &#39;StartPage&#39;,isLazy: true,key: &#39;3&#39;,select:true } &lt;/p&gt;    &lt;p&gt;]&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The key is the pageid to collect the underlaying children. For each click on the page node it will send the key/pageid to the service and it will respond with more children if there are any.&lt;/p&gt;&amp;#160;&amp;#160; &lt;h3&gt;Summary&lt;/h3&gt;  &lt;p&gt;Next step is to implement filtering to the pages that is returned and perhaps more intiutive icons for EPiServer page status, etc.&lt;/p&gt;  &lt;p&gt;But still, jQuery is the shit!&lt;/p&gt;  &lt;p&gt;(If anyone interested, download the project &lt;a href=&quot;http://www.internetfabriken.se/Global/jqueryTree.zip&quot; target=&quot;_blank&quot;&gt;here for EPiServer 5.2.375.133&lt;/a&gt; and VS2008)&lt;/p&gt;</id><updated>2009-03-25T17:26:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Easy made search function for EPiServer</title><link href="https://world.optimizely.com/blogs/Andreas-Ek/Dates/2009/3/Easy-made-search-function-for-EPiServer/" /><id>&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c01f8332-3539-491a-bc0c-215ae733aac2&quot; style=&quot;padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px&quot;&gt;Technorati-taggar: &lt;a href=&quot;http://technorati.com/tags/Search&quot; rel=&quot;tag&quot;&gt;Search&lt;/a&gt;,&lt;a href=&quot;http://technorati.com/tags/PageTextIndexDB&quot; rel=&quot;tag&quot;&gt;PageTextIndexDB&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;This is an easy example to find pages from a seachword into a pagedatacollection in EPiServer PageTextIndex database.&lt;/p&gt;  &lt;p&gt;Header for “using”:&lt;/p&gt;  &lt;p&gt;---&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#0000ff&quot;&gt;using System;      &lt;br /&gt;using System.Collections.Generic;       &lt;br /&gt;using System.Linq;       &lt;br /&gt;using System.Text;       &lt;br /&gt;using EPiServer;       &lt;br /&gt;using EPiServer.Core;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;---&lt;/p&gt;  &lt;p&gt;And the code to do the search in the EPiServer PageTextIndex database:&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008000&quot;&gt;---&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008000&quot;&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;/// Simple use of PageSearch with default value for PageID and MaxCount.       &lt;br /&gt;/// &amp;lt;/summary&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;SearchWord&amp;quot;&amp;gt;The word to search for&amp;lt;/param&amp;gt;       &lt;br /&gt;/// &amp;lt;returns&amp;gt;PageDataCollection&amp;lt;/returns&amp;gt;       &lt;br /&gt;&lt;/font&gt;public static PageDataCollection PageSearch(string SearchWord)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return PageSearch(SearchWord, PageReference.StartPage.ID, 100);     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;&lt;font color=&quot;#008000&quot;&gt;/// &amp;lt;summary&amp;gt;      &lt;br /&gt;/// Make a quick search to the EPiServer PageTextIndex database with this function.       &lt;br /&gt;/// &amp;lt;/summary&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;SearchWords&amp;quot;&amp;gt;The word to search for&amp;lt;/param&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;PageID&amp;quot;&amp;gt;Page ID of the root page to search from&amp;lt;/param&amp;gt;       &lt;br /&gt;/// &amp;lt;param name=&amp;quot;MaxCount&amp;quot;&amp;gt;Maximum count of pages in the result&amp;lt;/param&amp;gt;       &lt;br /&gt;/// &amp;lt;returns&amp;gt;PageDataCollection&amp;lt;/returns&amp;gt;&lt;/font&gt;     &lt;br /&gt;public static PageDataCollection PageSearch(string SearchWord, int PageID, int MaxCount)     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; PageDataCollection pages = new PageDataCollection();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; bool onlywholeword = false; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; EPiServer.Core.Html.TextSearchParameters searchparam = new EPiServer.Core.Html.TextSearchParameters(SearchWord, onlywholeword); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; if (searchparam.ContainsSearchWords)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EPiServer.Core.Html.TextSearchResults result = null;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EPiServer.DataAccess.PageTextIndexDB xdb = new EPiServer.DataAccess.PageTextIndexDB();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; result = xdb.SearchPages(searchparam, PageID, MaxCount); &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; List&amp;lt;EPiServer.Core.Html.PageRank&amp;gt; list = result.ToList();    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; foreach (EPiServer.Core.Html.PageRank pageRank in list)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; EPiServer.Core.Html.TextSearchMatch match = pageRank as EPiServer.Core.Html.TextSearchMatch;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (match != null)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; pages.Add(match.PageData);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; return pages;     &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Any other suggestion to easy search for content in EPiServer pages? It would be great!&lt;/p&gt;</id><updated>2009-03-22T17:52:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Workflows with EPiServer is really easy!</title><link href="https://world.optimizely.com/blogs/Andreas-Ek/Dates/2009/3/Workflows-with-EPiServer-is-really-easy/" /><id>&lt;div class=&quot;wlWriterEditableSmartContent&quot; id=&quot;scid:0767317B-992E-4b12-91E0-4F059A8CECA8:52a2ae45-0afa-4c54-8113-1d041074d628&quot; style=&quot;padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px&quot;&gt;Technorati-taggar: &lt;a href=&quot;http://technorati.com/tags/Workflow&quot; rel=&quot;tag&quot;&gt;Workflow&lt;/a&gt;,&lt;a href=&quot;http://technorati.com/tags/WFF&quot; rel=&quot;tag&quot;&gt;WFF&lt;/a&gt;&lt;/div&gt;  &lt;p&gt;Yes, I know, this is easy. Perhaps there’s someone who likes simple tasks as well ;-)&lt;/p&gt;  &lt;p&gt;{EpiServer Version: 5 R2 and Visual Studio 2008}&lt;/p&gt;  &lt;p&gt;I’ve earlier done some side event interactions with EPiServer, eg. when saving a page and save data to an external table for handling comments to a page (in this case an article). No, I will not use XForm data because we have to present the overall comment listings for the web editor, not just this page comments.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I’m going through a very simple and easy example of workflow in EPiServer here.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;1. Create a new project in your solution, a workflow project, eg sequential.    &lt;br /&gt;&lt;a href=&quot;/link/ee422902717e44fc9cab164de3d17129.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;164&quot; alt=&quot;image&quot; src=&quot;/link/2300e2662cb8424a92d35f5485d52daf.png&quot; width=&quot;244&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;2. Define a code block in your schema, eg SendMail and then double-click it!    &lt;br /&gt;&lt;a href=&quot;/link/bced136b6c724b5883cf72e88f0ffe10.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;172&quot; alt=&quot;image&quot; src=&quot;/link/0341feb7f85e433495232758626edd65.png&quot; width=&quot;160&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;3. Now, write your code for the event.    &lt;br /&gt;&lt;a href=&quot;/link/45f9d48b73a14bdca8cf3e66b4f6462f.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;171&quot; alt=&quot;image&quot; src=&quot;/link/12d11228f74244199c57937aa371785b.png&quot; width=&quot;504&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;4. Compile your workflow and make a reference in your project to the new made workflow!    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;5. Startup EPiServer and go to admin mode and Tools, workflows.    &lt;br /&gt;&lt;a href=&quot;/link/43973ba7ea9245ffb81ae3bde567c54b.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;149&quot; alt=&quot;image&quot; src=&quot;/link/2b6431571a71430ea1d7b0c1d28545d1.png&quot; width=&quot;165&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;6. Create a new definition for your workflow.    &lt;br /&gt;&lt;a href=&quot;/link/3141b54ca61f45da8af1c6bfb34bbaae.png&quot;&gt;&lt;img title=&quot;image&quot; style=&quot;border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px&quot; height=&quot;335&quot; alt=&quot;image&quot; src=&quot;/link/cbe89e8c311944eb9001eaf961fa3b48.png&quot; width=&quot;504&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;7. Map an event in EPiServer to the defintion, eg, Page Published against a pagetype.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;8. Now you’re done! Everytime a page of your pagetype is published your code will execute.    &lt;/p&gt;</id><updated>2009-03-21T11:03:21.7700000Z</updated><summary type="html">Blog post</summary></entry></feed>