When you want to alter a page programmatically you need to use EPiServers CreateWriteableClone on the working page. This is because the Page itself is readonly. Now, there’s plenty of info out there how to do this, but just to refresh your mind, here’s some code:

PageData clone = pd.CreateWritableClone();
clone.Property["MyProperty"] = "New value";
DataFactory.Instance.Save(clone, SaveAction.Publish);

Simple enough, right?

Now, here’s the catch. If you are for example saving page ID’s into a customproperty, simply like this ”42 43 553 23” and so forth and you want to change this programmatically by removing one and adding one. So for example, going from ”42 43 553 23” to ”42 43 55” won’t work with the code above. The result will be ”42 43 553 23 55” as it will only add it up to your current value. So you want to clear your value before you set it although that is also not enough. You’ll have to save the page after you clear it and THEN you can set your new value and save the page. Something like this

PageData clone = pd.CreateWritableClone();
clone.Property["MyProperty"].Clear();
DataFactory.Instance.Save(clone, SaveAction.Publish);
clone.Property["MyProperty"] = "New value";
DataFactory.Instance.Save(clone, SaveAction.Publish);

If someone has a better way to override values without having to doublesave, please do let me know.

FindPagesWithCriteria is a very handy way to pick up pages that are spread out around your site but there’s a tiny thing that is good to remember when using FindPagesWithCriteria to find pages based on a CustomProperites that you’ve made. Never ever forget to click ”searchable property”  when you add the customproperty to your page. Why? Because if this is not checked, FindPagesWithCriteria won’t be able to find it, simple 🙂

Tiny post for a tiny problem that can cause a lot of headache 😉

Google Buzz is out and most of you will see it just below your inbox. But since a lot of people already use Twitter, google would’ve made a huge mistake not to let users connect their twitter account to their google account. They did implement it but not as good as you would’ve hoped.

Anyway, once you click on the Buzz link, you’ll see your information on the top of the page and click on ”linked webplaces” ( mine says ”länkade webbplatser” ‘cuase it’s on swedish).

You’ll get a list of supported webplaces you can connect too.

Choose what to connect too (in this case Twitter) and press the ”Add” button (”Lägg till” due swedish as mentioned before)

Then just fill in your twitter username and click ”Connect” (”Anslut” once again… swedish)

and you’re all set!

The silly thing about this is that you’ll never do an authentication with Twitter, you just grab a username, meaning that you can choose whomever’s twitter account. That would be silly but still. They’re just grabbing the users feeds and showing it on your buzz.

Anyways, it’s that simple but lets hope that we get a proper integration of Twitter in gmail – Buzz.

So you have an Android phone but can’t buy a single application? Some app creaters have made it possible to let you buy the game on their website and then enter the key yourself. But the people over at SlideME did a very nice solution for all of us that wants to buy apps and can’t wait until we can get it (hopefully in march)

It’s very very handy. All you need to do is register an account at their website and add your creditcard to it. Download Mobentoo Marketplace, install it and just browse around, pretty much like Android Market, but this one has atleast sorting and better category overview.

This will open up quite a few apps and games for you at affordable prices. Most of the games and apps go for $0.99, but the ”better” ones go for between 2-4 dollars.

I bought Speed Force 3D and it works incredibly great! Smooth installation and no need to enter the key myself. Also, SlideME will give you access to all your transactions through their website and also the possibility to browse the market directly from the webpage.

Anyways, I truly recommend this solution for all you Android users that just don’t have patience enough (like me 🙂 )

It’s been over a month now and I’m truly loving my HTC Hero. We had a lab at work where we made a simple stepcounter for android and was a nice introduction into programing for android. But now I was thinking about sharing few of the application and games installed on my phone. Specially since you start off installing whatever comes your way just cause it’s fun and simple 🙂

Applications (in no significant order)

* Handcent SMS. Just a very very very nice sms app. Gives you a better overview, more settings, smilies an da nice quickreply window. Everyone has this one on their toplist and I just can’t help to have it there aswell 😛

*NewsRob: It’s not the best, but certainly a very comfortable and working application. This app synchronizes with your Google Reader account and also downloads the feeds, letting you browse them offline. This is great for people that lacks a flatrate deal on their phone or if you’re in a train and there are a lot of tunnels in the area 🙂

* Twidroid. I actually bought this app which is the one and only bought application on my phone, since we swede’s can’t buy anything from Android Store (PLEASE LET US!). This is a great Twitter client with a great widget and plenty of settings. You can also add several accounts incase you have an alter ego or some secret account.

* Taskpanel. Android takes well care of your phone and ends applications when it needs to free up memory. But for people that can’t really help themselves to have control over their phone, it’s great! Let’s you kill applications or even all of them with single tap.

* Ringdroid. This sweet little app let’s you cut and edit tunes on your phone, letting you create sweet signals, alerts… well, you name it! 🙂

* Spotify. Do I even need an explination? 🙂

* Eniro.se. This is a great application! it might steal some battery, I don’t know. But it’s worth it even if it does! Whenever you get an incoming call, if you don’t have the phone number as a contact, it will look the number up and give you a toast (androids tiny little window with a message) with who it is. It has been of great use!

* Market Suggest. This will look at what you have installed and search for stuff that you might like. I’ve actually found three apps (don’t use them THAT rarely though) and two games this way.

*Prisjakt. Just a simple awesome application. If you’re at Elgiganten or OnOff or whatever swedish store, remember to use this on whatever you are planning to buy. It’s really helpful!

* Soccer Livescore. Great app to follow live scores on football games played all over the world.

Games (in no significant order)

* Gem Miner. Great game and a great timekiller 🙂 You play as a little gem miner and you just dig dig dig dig. You have to use different tools like ladders, pillars, elevators and much more. Really fun!

* Monkey Kick Off. Simple but fun game! Kick a coconut as far as you can 🙂

* Jewels. Old faithful. Great game, simple as that 🙂

* Papi Jump. Try it! first you might think ”wth is this??” but it’s addictive!

* Zebra Paint. My kids loves this game. Whenever we’re somewhere and their attention level is set on HIGH, then this game comes like a gift from heaven 🙂

* 2 player reactor. This is a GREAT game. lots of minigames that you can play against someone else. I really recommend this one.

The reason why I have these applications and games on ”my list” is because I truly use them all. Some several times per hour, some per day and some per week. Sure, I think I’ve over 100 different things installed but the majority are used just once in awhile. I hope that you can find any of these tip useful and find your new favorite app/game 🙂

One of the pages I’ve been working on uses EPiServers categories a lot. But the annoying part with EPiServers categories is the way they inherit down to all children, which leads to the problem that categories can be deleted without someone meaning too. e.g you create a page called ”Books” and you have a control that creates a category using the pagename. Below ”Books” you’ll add all the books you want, but all those books will get the category ”books” aswell. But to prevent dead categories, you might want to make a check that once you delete a page, you’ll also delete the category. Then, when deleting a childpage, you’ll also delete the real category, since the childpage also had this category. There are of course ways to prevent this but this can easily be forgotten and cause future problems. It will also mess up search results that uses categories to find information and so on.

Enough with examples, let’s get on the easy solution.


EPiServer.DataFactory.Instance.PublishingPage += CreateCategory;

EPiServer.DataFactory.Instance.SavedPage += CreateCategory;

EPiServer.DataFactory.Instance.SavingPage += CreateCategory;

EPiServer.DataFactory.Instance.CreatingPage += CreateCategory;

static void CreateCategory(object sender, EPiServer.PageEventArgs e)

{

if (!ValidPage(e.Page.PageTypeID))

{

e.Page.Property["PageCategory"].Value = string.Empty;

}

}

Basicly, you’ll call the method ”CreateCategory” whenever you create, save or publish a page. Then use a method to determinate if the pagetypeid of the page you are creating is a validpage (i.e you don’t want these pages to inherit categories) and then just give it a string.Emtpy as PageCategory value.  Whatever the situation, just make a method to check if you want the page to inherit the category or not, then use the code above.

Hope this helps

EPiServer.DataFactory.Instance.PublishingPage += Instance_SavingPage;
EPiServer.DataFactory.Instance.SavedPage += Instance_SavingPage;
EPiServer.DataFactory.Instance.SavingPage += Instance_SavingPage;
EPiServer.DataFactory.Instance.CreatingPage += Instance_SavingPage;

Googlewave invites arrive to those who wait, just like a Christmas gift 😛 But on a serious note. When you have a googlewave account, you eventually get a few invites to give away. I still have 10 to give away so just add a comment here (with your email ofc) and I’ll be sending one your way.

Goolewave to the people! Viva Google! 😛

HTML 5 introduces new elements to use such as <header> <section> <nav> and many more. The problem is that no version of Internet Explorer recognizes the new elements, but Firefox, chrome and many others does. The solution is easy but a bit boring when you think about it, since it’s about replacing all new elements to div instead. Which means that IE users won’t be able to appreciate HTML5 but users that use Firefox, Chrome and so on will.

Anyway, on with the solution! What you need to do is modify the writer and basically find all elements and change them with a div.  A good place to do it on is on your masterpage.

protected override void Render(HtmlTextWriter writer)
{
if(Request.Browser.Browser == "IE")
HTML5Replace(writer);
else
base.Render(writer);
}

private void HTML5Replace(HtmlTextWriter writer)
{
MemoryStream memoryStream = new MemoryStream();
StreamWriter streamWriter = new StreamWriter(memoryStream);
HtmlTextWriter memoryWriter = new HtmlTextWriter(streamWriter);
base.Render(memoryWriter);
memoryWriter.Flush();
memoryStream.Position = 0;
TextReader reader = new StreamReader(memoryStream);
string output = reader.ReadToEnd();
output = Regex.Replace(output, RegExStrings.HTML5_BLOCK_ELEMENTS , RegExStrings.HTML5_BLOCK_ELEMENTS_REPLACEMENT );
writer.Write(output);
}

But what REALLY does the magic is the RegEx, since it will find the elements for you and replace them correctly.

public const string HTML5_BLOCK_ELEMENTS = @"<(\/)?(nav|section|header|aside|footer)";
public const string HTML5_BLOCK_ELEMENTS_REPLACEMENT = @"<$1div";

The reason why I use $1 on the replacement string, is because I want to add a ”/” if there is one in the element I found. This to close the tag correctly. So basically, when it finds ”<nav” it will replace it with ”<div” and when it finds ”</nav” it will replace it with ”</div”. Closing tag and class/id names will still be there so the div can take on the behavior of the replaced element.

Another problem that you will run into, if you’re running your site with EPiServer that is, is that EPiServers friendlyurlrewriter doesn’t recognize the doctype and it will try to fix it for you. For HTML 5 you’ll need the following doctype  ”<!DOCTYPE html>” but EPiServer will change it to the following ”<!DOCTYPE HTML PUBLIC ”” ””>”. Mohsen Pirouzfar found a great solution for this which you can read here. It’s in swedish but the code itself is usable to anyone 🙂

We’ve had huge problems with the testserver. It first felt like a cache problem, because when you updated the content and hit refresh several times, you saw the changes and then you didn’t. Also, pages that were dependant on session state were giving null expressions since the state was empty sometimes.

The problem was in the Application Pool. DefaultAppPool was for some odd reason by default set to 3 worker processes which makes it a web garden (used for load-balancing) and this caused the user to get the errors mentioned above, since only one of the worker process actually had a valid session, the others didn’t.

worker

After upgrading EPiServer CMS5 r2 to CMS5 r2sp2 you might get a nice little error in edit mode. This page is not available for the active language. This is due globalization changes and the workaround is to activate a language for your site. To do this do the following:

1. Go to admin mode
2. Click on Config
3. Go to systemsettings
4. Activate Globalization
5. Go to Edit mode
6. click on Language Settings
7. Chose the default language
8. Go back to admin mode
9. Turn off globalization

This should do the trick. Remeber, if you have several sites, you need to click on the root of each one of them and set the language settings on all of them.