EPiServer

You are currently browsing the archive for the EPiServer category.

At the moment I'm adding some functionallity to vinsprit.se, so that a visitor can add products, that aren't in the regular assortment, to a cart and by a simple click send this cart by fax to the closest Systembolag. A pretty nice feature. The customer also wanted to store the orderinfo in episerver if something goes wrong, so I thought that you must be able to do that with XForms. And yes, it was very simple.

First of all I added a "XForms form"-property to the pagetype. Then I made an empty Form. The rest is handled from code behind. The following example works both with 4.6 and CMS 5. Hopefully in CMS 5 R2 aswell.. :)

// Get guid for the form and creates instance
XForm form = XForm.CreateInstance(new Guid((String)CurrentPage["XFormPropertyName"]));
// This is where data is stored
XFormData form_data = form.CreateFormData();
//We want this info related to the order page
form_data.PageId = CurrentPage.PageLink.ID;
// We want it saved in the database
form_data.ChannelOptions = ChannelOptions.Database;

// Here we add the values.
form_data.SetValue("Key 1", "some value");
form_data.SetValue("Key 2", "some other value");
// and saves it
form_data.Send();

Pretty nice if you want to avoid creating your own sql-table or some other way to store data.

Tags: , , ,

I know there is a great MultiPage Property on EPiCode, but sometimes I want to use a bit more simple MultiPage picker, and not be able to choose to link documents and other pages etc. So when I had some spare time a few weeks ago, I wrote my own multipage property.

To make the property as powerful as possible I've added the oppertunity to specify the startnode when you add a page, and there is also a possibility to choose wich PageTypes you are allowed to use. If you leave the help-text blank you will be able to add all pagetypes and the startnode will be the start page. Defining these values in help-text may not be the best way to go, but it's the easiest way if you want it as dynamically as possible. I usually change where to define these values in my projects, etc a settings page or web.config, but in this case the help text is wonderful. :)

If the editor tries to add an invalid page type, the following msg will appear.

To get the selected pages when you code, just use this line

PageDataCollection pdc = Obg.SpecializedProperties.Util.MultiPage.GetPageDataCollectionByPropertyValue(CurrentPage["MultiPageContacts"]);

You can download the file here: MultiPage Property (binaries)

In this dll, my DropDown Property is also added.

Feel free to give me feedback on these properties or you want the source code etc.

Tags: , , , , , ,

Got so frustrated yesterday that I hade to leave one hour earlier. Must have been very tired cause I couldn't manage to get Friendly URL running with EPiServer 4.6 on Vista, even though I have managed to do it before.

Well, this morning I solved it in a few minutes.. :)
The problem was that in IIS7, you have to specify how the IIS handles error pages, it's not enough to just change 404 to /Util/NotFound.aspx. By default, IIS gives you detailed information on what went wrong, you have to change this so it uses yours/episerver notfound-page.

Then you have to make sure that you run Classic mode in your App-pool and that your <module> in web.config says <module runAllManagedModulesForAllRequests="true">

You can read more at http://world.episerver.com/Forum/Pages/Thread.aspx?id=12984&epslanguage=en.

Good luck

Tags: , , , , ,

Made a joblisting about a month ago, the site I made it for is a globalized site with three different languages (so far). Every work ad needs a start- and a stop-publish date, and the work ad is first created in one language, then translated by some other to other languages.

When I checked around the site a week ago i noticed that the joblisting had different sorting depending on what language I had choosen. So I started my research and noticed that the start- and stop publish was only set in the master language, and the other pages had a different start publish and no stop publish... Of course, you need to set publish dates on all languages. This was not an option..

Then I remembered that you can prepopulate data in the edit-fileds, but how? Started thinking again.. global.asax.. events.. hmm.. advanced developing with episerver, that's right. Found my course material and checked a random page in it, and there it was! So this is how I solved it:

In Global.asax

protected void Application_Start(Object sender, EventArgs e)
{
DataFactory.Instance.LoadedDefaultPageData += new PageEventHandler(Instance_LoadedDefaultPageData);
}

protected void Instance_LoadedDefaultPageData(object sender, PageEventArgs e)
{
if (e.Page.PageTypeID == Utils.Settings.PageTypeJobitem && e.Page != null && e.Page.PageLink != PageReference.EmptyReference)
{
PageDataCollection languages = DataFactory.Instance.GetLanguageBranches(e.Page.PageLink);
if (languages.Count > 0)
{
e.Page.StartPublish = languages[0].StartPublish;
e.Page.StopPublish = languages[0].StopPublish;
}
}
}

Tags: , , ,

Had some trouble loading a vitrual file containing spaces.

The problem was apperently that some characters were urlencoded, a simple Server.UrlDecode(CurrentPage["DocumentPath"]) solved the problem. :)

Tags: , ,

I've had some problem to link to a page to another language then the current language.
Even though I have a PageData-object with anouther languagebranch, it stills makes a link to the current language.

My own solution, building a url by CurrentPage.StaticLink and adding epslanguage=langID, works but it's not how I want to do it.

So today I found the EPiServer.UriSupport class. In that class you have EPiServer.UriSupport.AddLanguageSelection(pd.LinkURL, pd.LanguageID), just what I've been looking for.

Tags: , , , ,

VirtualFile file = System.Web.Hosting.HostingEnvironment.VirtualPathProvider.GetFile( CurrentPage["FilePath"].ToString() );
UnifiedFile f = file as UnifiedFile;
return f.Length / 1024 + " kb";

Tags: , , ,

The new properties AppSettings and AppSettingsMultiple in EPiServer CMS 5 is a pretty nice feature, but when yesterday when I tried to implement it, I had a hard time finding out how to do it. But finally I did.

First of all, in edit mode, AppSettings will create a DropDown and AppSettingsMultiple will create a CheckBoxList.

To create you AppSettings property you have to define some values in <appSettings> in your Web.Config, i did like this:
<add key="PropertyCountries" value="Czech republic;CR|Sweden;SV|United Kingdom;UK" />

Now you just have to add a Property to your pagetype with the name PropertyCountries and you are done.

When you use the AppSettingsMultiple the CurrentPage.Property["PropertyCountries"].Value will return a comma separated string with the selected values, like "SV,UK" and you just have to do a simple .Split(',') and you have a string array.

new FilterPropertySort("PageName", FilterSortDirection.Descending).Filter(children);

Tags: , , ,

In EPiServer.Filters there are some useful filters, like FilterPublished, FilterAccess etc.

To use these filters, just do like this:

new FilterPublished().Filter(somePageDataCollection);

and it's done. :)

Tags: , , ,

« Older entries § Newer entries »