Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Blog function for users

Vote:
 

We've started working on a blog function for our registered users and have started thinking about how to deal with this programmatically. Can we use the Blog module for this, to create the pages in the code behind? If so, is there any documentation on this to turn to?

#39797
Jun 02, 2010 8:03
Vote:
 

There is already a blog module that ships with the demo templates that you could use as a starter kit. For code on creating new pages in EPiServer see the "Get started" section.

Hope this helps

Frederik

#39800
Jun 02, 2010 9:03
Vote:
 

How do I install the demo templates when using 5.2.375.236? 

#39801
Jun 02, 2010 9:30
Vote:
 

First install CMS 5 R2 SP1, then download the templates and install them. Open up deployment center and choose install demo templates under "Version 5.2.375.133", when the wizard starts make sure to select "Show all sites" under step 2 - choose your CMS 5 R2 SP2 site and you're good to go :).

#39803
Jun 02, 2010 9:44
Vote:
 

When I get to step 2 in the Demo Templates installation there is no where to select "Show all sites". All there is is my development site from SP2 and if I choose to install to it it says that it's not an EPiServer CMS 5 application.

#39804
Jun 02, 2010 10:36
Vote:
 

How many sites do you have locally? If you only have the one, you might need to install another site just to make the "Show all sites" checkbox display..

#39805
Jun 02, 2010 10:56
Vote:
 

I created a little test site in an entirely different virtual machine where I can try this code out. Should I just copy the Blog-folder to my regular project? I also saw something about an event handler that needed to be added to the web.config.

#40006
Jun 08, 2010 16:00
Vote:
 

I think you need some code from the Forum folder as well.. And yes, you need to register an HttpModule for the blog :). See this blog post for setup instructions.

Cheers

Frederik

#40010
Jun 08, 2010 16:44
Vote:
 

There are also some language statements in the lang files that you should copy to a new language file.

#40013
Jun 08, 2010 22:02
Vote:
 

Thanks guys, I'll give this a go as soon as I've taken care of some other issues. I'll get back to this thread later on if run into some complications.

#40024
Jun 09, 2010 9:39
Vote:
 
#40057
Jun 09, 2010 14:25
Vote:
 

I noticed that step 3, mentioned in the blog above, is not in the web.config of the demo templates. How come?

#40060
Jun 09, 2010 14:32
Vote:
 

There is a bug when installing the demo templates under IIS 7 or above, where the HttpModule doesn't get registered in the web.config file.

#40061
Jun 09, 2010 14:39
Vote:
 

Aha, ok. That explaines it.

I've added all the pages and classes needed (there were a few) and it compiles but I get a server error when running the site pointing to the lines in web.config containing:

<sectionGroup name="episerverModules">
  <section name="episerver.Blog" type="EPiServer.Blog.ConfigurationHandler, EPiServer.Blog"/>
</sectionGroup>

Have I added this to the wrong place perhaps? It's at the beginning of web.config, last in the configSection.

#40064
Jun 09, 2010 15:01
Vote:
 

What error message do you get?

#40068
Jun 09, 2010 15:22
Vote:
 

"When I get to step 2 in the Demo Templates installation there is no where to select "Show all sites"."

After installing EpiServer 5 R2 SP1 and installing the demo template, if you then run EPiServerShared.msi from EpiServer 5 R2 SP2 again, it will then show the 'Show all sites' option for the Demo Templates in deployment centre.

If that doesn't work then a repair install of EpiServer 5 R2 SP2 will put the 'show all sites' option back.

The issue occurs because installing EpiServer 5 R2 SP1 over the top of a SP2 install downgrades the EpiServer Shared files which includes the deployment centre, so the deployment centre from SP2 needs to be upgraded again.

Dave Green

#40069
Jun 09, 2010 15:45
Vote:
 

"Section or group name 'episerverModules' is already defined. This can not be defined multiple times." That's true but it's what it tells me to do in the blog. I'm obviously missing something here... :)

#40070
Jun 09, 2010 15:47
Vote:
 

Seems that it's defined to places in your web.config file. Do a search for episerver.Blog, and make sure it's only added once.

#40071
Jun 09, 2010 15:50
Vote:
 

It was defined from the start but empty so I missed it.

I'm going to create the page types and start trying it out. I'll probably be back to this thread if I run into any problems. Thanks for all the help so far!

#40132
Jun 10, 2010 8:29
Vote:
 

Helgheim mentions in his blog (in the usage section) that ones you create the Blog team page there will be two child pages created automatically, Tags and Dates. That is if the httpmodule is registered correctly. I didn't get these child pages but the httpmodule is registered. Can I create these manually or do I have to fix this problem?

Also, in the code BlogItems function in the code behind of TeamStart.aspx it says if (_blogItems == null) that need to be set to != null. Is it to small of a bug to even be mentioned or should this perhaps be reported somewhere?

#40152
Jun 10, 2010 11:51
Vote:
 

Try create a personal blog and add a blog post. Tags and dates should be created. If not there is something wrong with the httpmodule.

#40153
Jun 10, 2010 11:53
Vote:
 

I tried creating a Personal blog under the Blog team page but I get this error message and I'm not sure what it's about. It's line 48 that causes the crash.

 

Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error: 
Line 46:             {
Line 47:                 DynamicProperty blogStart = DynamicProperty.Load(CurrentPageLink, BlogUtil.StartPropertyName);
Line 48:                 blogStart.PropertyValue.Value = CurrentPageLink;
Line 49:                 blogStart.Save();
Line 50:             }
 

Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error: 

Line 46:             {

Line 47:                 DynamicProperty blogStart = DynamicProperty.Load(CurrentPageLink, BlogUtil.StartPropertyName);

Line 48:                 blogStart.PropertyValue.Value = CurrentPageLink;

Line 49:     blogStart.Save();

Line 50:             } 

 

#40158
Jun 10, 2010 12:42
Vote:
 

I believe there is a dynamic property that you need to add, which sets the personal blog page start. See your demo setup for name and type.

#40159
Jun 10, 2010 12:57
Vote:
 

It's as fredrik says a dynamic property check the blogutil.startpropertyname property for the name. I think its BlogStart.

#40160
Jun 10, 2010 12:59
Vote:
 

Oh yes, that's right. The property BlogStart is suppose to be set automatically so I guess that httpModule is not set up correctly. This is what it looks like and I can't really see anything wrong with it.

 

<httpModules>
      <add name="BlogHandler" type="EPiServer.Blog.EventHandlers, EPiServer.Blog"/>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>

 

<httpModules>

<add name="BlogHandler" type="EPiServer.Blog.EventHandlers, EPiServer.Blog"/>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</httpModules>

#40161
Jun 10, 2010 13:02
Vote:
 

Then on the other hand, this property and the dates and tags pages aren't created in the demo site either so I guess I'm all good? :)

#40165
Jun 10, 2010 14:34
Vote:
 

No... I'm not... :/

Any ideas to where to go from here?

#40166
Jun 10, 2010 14:55
Vote:
 

I've been looking around some more and I'm getting really confused. I'm looking at the Demo site that I installed. It has three blogs under the Team Blog Start page. The Team Blog Start page has the dynamic property BlogStart pointing to itself and judging from Helgheims blog this is set automatically. Same thing with every Personal Blog Page underneath this Team page, the dynamic property is set to itself, and all of the blogs have the Date and Tages folder underneath them.

If I look at my own site where I try to implement this I start out by creating the the Team page. The dynamic property is not set to point at itself automatically but if I create a personal blog underneath this one is. Both of these pages crash on their data binding because of the BlogItem-function that I mentioned earlier. I started out thinking this was a bug going off while there were no items to fetch but that was not the case.

So I figured there must be something wrong with the web.config-setup that we've discussed earlier so I go to the Demo site to try it out. I created a Team Blog Start page and noticed that this one didn't have its dynamic start page pointing to itself automatically either. Strange, since the one included in the installed Demo site is. Figured I'd do this manually and then created the Personal Blog underneath. This page gets it's dynamic property set correctly so this far it's just like my own site with the exception that it doesn't crash on the data binding. I then create a blog item and I don't get the Tags and Dates pages like it is in the other blogs in the Demo site. My Blog Item is created just like a regular page. Even if I create a new Personal page underneath the Team page that comes preinstalled with the demo site I don't get the Tags and Dates pages like in the other blogs.

What's up with that? :)

#40174
Jun 11, 2010 8:49
Vote:
 

Register the HttpModule in your demo sites web.config file (remember that there are differnt placements depending on if you're using IIS 6 or below or IIS 7 or above). If you now create a new personal blog in your demo site the dynamic property should get set and the date and tags pages created.

#40175
Jun 11, 2010 8:55
Vote:
 

I find myself in your situation aswell that I don't get the BlogStart set automatically and the date and tag pages aren't created either. I have it setup in a R2 SP1 IIS6 on an xp machine and all works well there.

In the environment Im trying to set up is a R2 SP2, IIS7 on windows 2008. I've registred the httpModule like this:

<

<

<

</

 

 

 

system.webServer>modules runAllManagedModulesForAllRequests="true">add name="BlogEventHandlers" type="EPiServer.Blog.EventHandlers, EPiServer.Blog" preCondition="managedHandler" />modules>

But when I check the iis I can't see it so something is definetly wrong.

 

#40176
Jun 11, 2010 9:02
Vote:
 

I'm using IIS 7 and it's registered right at the end of the system.web-tag.

 

    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="BlogHandler" type="EPiServer.Blog.EventHandlers, EPiServer.Blog"/>
    </httpModules>
  </system.web>

   <httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add name="BlogHandler" type="EPiServer.Blog.EventHandlers, EPiServer.Blog"/>    </httpModules>

</system.web>

 

#40177
Jun 11, 2010 9:05
Vote:
 

Per, good to here I'm not the only on then! :) I'm running Windows Server 2008 as well.

#40178
Jun 11, 2010 9:07
Vote:
 

In IIS 7 it should be registered under the system.webServer section. Also make sure that the modules for starting up EPiServer and the right events are registered before the blog module.

<system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
            <add name="InitializationModule" type="EPiServer.Framework.Initialization.InitializationModule, EPiServer.Framework" preCondition="managedHandler"/>
            <add name="FirstBeginRequestModule" type="EPiServer.Web.InitializationModule, EPiServer" preCondition="managedHandler"/>
            <add name="Initializer" type="EPiServer.Scheduler.Initializer, EPiServer.Scheduler" preCondition="managedHandler"/>
            <add name="BlogHandler" type="EPiServer.Blog.EventHandlers, EPiServer.Blog" preCondition="managedHandler"/>
            ...
        </modules>
        .....

#40180
Edited, Jun 11, 2010 9:10
Vote:
 

I hade registred the httpmodule wrong. Check for the system.webserver where episerver registers their own modules (search for urlrewrite).

Now it's registred but I got some other error. I guess Im gonna try dumping the httmodule with relector, rebuilding and debugging.

 I can create a blogstart and it creates the dates and tags pages. But I get some error when trying to make a blog post.

#40181
Edited, Jun 11, 2010 9:15
Vote:
 

Yes, that did the trick! Now the Dates and Tags pages are created. Thanks!

I also found that the name of the page types used for the blog where hard coded in the BlogUtil.cs. Helgheim only mentioned the ones in the web.config but if you change the names of the page types you also need to change them in this class. That's what caused the data binding to crash.

I also had some problem with the blog comment-box so that's up next.

#40184
Jun 11, 2010 10:14
Vote:
 

It's the <%@ Register TagPrefix="wym" Namespace="EPiServer.Templates.Demo.RichTextEditor" Assembly="EPiServer.Templates.Demo" %> that causes the problem. It says "Could not load file or assembly 'EPiServer.Templates.Demo' or one of its dependencies. The system cannot find the file specified." All I've done is copying the directories. Do I need to add a reference or something to get this running?

#40185
Jun 11, 2010 10:32
Vote:
 

The namespace should be correct but what about the assembly? Do I need to copy some more files or should something be changed somewhere?

#40311
Jun 14, 2010 8:22
Vote:
 

I solved it!

If anyone's still reading this :) I'm about to create the interface for the users where they can choose to create their blog and start posting blog items. Any tips on how to go about? I need to make this a secure way to post them. My thought was to maybe create a table where I can store the user id and blog start page id and always check that it's the correct logged in user who gets his/her blog info but I'm sure this can be done directly in EPiServer, right?

#40570
Jun 14, 2010 11:34
Vote:
 

Or perhaps store the page id of there blog page in the profile and use that to reference what pages they are entitled to?

#40573
Jun 14, 2010 12:28
Vote:
 

I noticed that the BlogList-function that fetches the blogs for the blog team start page doesn't pay any attention to the different languages that are used on the site. It fetches all the languages. Myfirst thought was to change the page list that gets the recent blog items from using a data source to the current page link and then filter out the tags dates pages. But perhaps there is a way to rewrite the data source function? This is the on that is used.

protected PageDataCollection BlogItems
{
    get
    {
        if (_blogItems == null)
        {
            PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
            criterias.Add(BlogUtil.CreateCriteria(CompareCondition.Equal, "PageTypeID", PropertyDataType.PageType, PageType.Load(BlogUtil.ItemPageTypeName).ID.ToString(), true));
            criterias.Add(BlogUtil.CreateCriteria(CompareCondition.GreaterThan, "PageStartPublish", PropertyDataType.Date, DateTime.Now.Subtract(HistoryLength).ToString(), true));
            _blogItems = DataFactory.Instance.FindPagesWithCriteria(CurrentPage.PageLink, criterias);

            FilterForVisitor.Filter(_blogItems);
            new FilterSort(FilterSortOrder.PublishedDescending).Filter(_blogItems);
        }
        return _blogItems;
    }
}

#40937
Jun 23, 2010 13:07
Vote:
 

How come I can't use this critera? It removes everything from the list.

criterias.Add(BlogUtil.CreateCriteria(CompareCondition.Equal, "LanguageBranch", PropertyDataType.String, countryCode, true)); 

#40938
Edited, Jun 23, 2010 14:02
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.