Get content from paragraph – Dynamicweb and Razor

Dynamicweb CMS allows you to get content from a certain paragraph – by using the following template-snippet:


This works fine in a regular HTML-template. However, Dynamicweb CMS has a rather new feature that allows you to use Razor-templates instead, and in these the above mentioned method doesn’t work. Thankfully, a colleague of mine (Morten Bengtson as usual) showed me how to do it properly in Razor:

<div class="span9 contactInfo">
        var pageView = Dynamicweb.Frontend.PageView.Current();
        var item = Dynamicweb.Content.Items.ItemManager.Storage.GetById(Dynamicweb.Base.ChkString(pageView.Area.get_Value("AreaItemType")), Dynamicweb.Base.ChkString(pageView.Area.get_Value("AreaItemId")));
        var ContactInfoParagraphID = Dynamicweb.Base.ChkInteger(item["ContactInfoParagraphID"]);

So we went from a very simple approach that took only line to a much harder to remember approach. I guess you can’t always win. šŸ™‚


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s