1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Developing blogs

Developing blogs

9 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    06 Oct 2009
    Link to this post

    Hi!

    I want to organize on my site two types of blogs. First type is personal blog of each user of my site and the second type is corporate blog. Can somebody suggest me how to organize this types of blogs with Sitefinity? The main question for me is site perfomance but if I create one page for each person it will decrease it. 

    Thank you.

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Oct 2009
    Link to this post
    Hi Paul,

    Thank you for using our services.

    Well I do not think that creating a blog page for each blogger will hinder your performance a lot. Take a look at our blog sites - the Telerik Blogs, and Sitefinity Blogs. They are both running on Sitefinity and if you take a look at the number of bloggers on the Telerik Blogs site you will see what I am talking about. Having a site with a hundred bloggers, that all have their own blog page is the same as having a site with a hundred pages all using content from the modules.

    Consider the following example. You create a Blog page on your site that will display all blogs. Then as children pages you will create a page for each blog. E.g. if the main blogs page is ~/blogs.aspx, for blogger A you will create a page ~/blogs/bloggera.aspx, and set the blog posts control on that page to display blogs only from blogger A's blog. In your Blogs module you will create a blog for each blog author, and a blog for your corporate blog. When you set each blog, you should make the Blog page property point to the page for each persional blog. An example with  blogger a will be ~/blogs/bloggera.aspx see attached image. In this way, wherever you place a Bloggers control in your site, users will be redirected to the appropriate blogger page.

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    07 Oct 2009
    Link to this post

    Hi Radoslav!

    Thank you for reply. I will organize blogs as you describe.

  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    07 Oct 2009
    Link to this post
    Hi Paul,

    You are more than welcome. Please feel free to contact us if you experience any troubles implementing your website.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    07 Oct 2009
    Link to this post

    Hi Radoslav!

    Can you help me with other complex problem? I want to create blog for a new user of my site: user registers on my site and after this new blog creates for him. How can I override default methods for user creation or how can I add this functionality? 

    Thank you.

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Oct 2009
    Link to this post
    Hello Paul,

    Below is a sample implementation of the desired functionality. I am using CreateUserWizard control and Blogs API.

    protected override void OnInit(EventArgs e) 
        { 
            base.OnInit(e); 
     
            this.CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser); 
        } 
     
        void CreateUserWizard1_CreatedUser(object sender, EventArgs e) 
        { 
            UserManager manager = new UserManager(CreateUserWizard1.MembershipProvider); 
            string role = "Bloggers"
            if (!Roles.RoleExists(role)) 
            { 
                Roles.CreateRole(role) 
            } 
            else 
            { 
            manager.AddUserToRole(CreateUserWizard1.UserName, role); 
             
            this.ManageProfile.SetProfileProperties(CreateUserWizard1.UserName); 
            var bManager = new BlogManager("Blogs"); 
            IBlog newBlog = bManager.CreateBlog(); 
            newBlog.Author = CreateUserWizard1.UserName.ToString(); 
            newBlog.Owner = CreateUserWizard1.UserName.ToString(); 
            newBlog.Name = "New User"
            newBlog.Description = "This is your blog"
            newBlog.BlogPage = "~/Bloggers.aspx"
            bManager.SaveBlog(newBlog); 
            } 
        } 
     
     
    You can extend the logic by crating a custom page for this blogger and automatically adding BlogPosts control to this page. I hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    09 Oct 2009
    Link to this post
    Hi Ivan!
    Thank you for code snippet! It is really helpful!
    But I met other problem in my development. I create page for new user after that I create blog and in the end I want to set template or the new page and add BlogPosts control to it. In API I met some good examples but in my case code doesn't work. 
    This is a code snippet which I use to set template and add BlogPosts control. But I get two type of error:"You cannot change a value of an object that is not in transaction." and other error then I'm trying to publish my page.

    Telerik.Cms.ICmsPage cmsPage = cmsManager.GetPage(postsPage.ID, trueas Telerik.Cms.ICmsPage; 
    Telerik.Cms.IPageTemplate outhereTemplate = cmsManager.GetTemplate("OuthereTestTemplate"); 
    cmsPage.Staged.Template = outhereTemplate.Template; 
    BlogPosts bpControl = new BlogPosts(); 
    cmsPage.Staged.AddControl("BlogPostsHolder", bpControl); 
    cmsPage.Publish(); 

    Can you help me with this problem? How does I need to publish my new page?
    Thank you.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Oct 2009
    Link to this post
    Hi Paul,

    Thank you for getting back to us.

    In order to add controls to the page and edit it, you must have it "Checked Out." This will let you edit the control collection, and template of the page you have just created. Please consider the sample bellow:
    CmsManager manager = new CmsManager();
    ICmsPage page = manager.CreatePage("TestPage");
    page.MenuName = "Test Page";
    page.Description = "This is my page description.";
    page.Navigable = true;
    page.Keywords = "Page,Keywords";
    page.DenyAnonymous = false;
     
    //checkout page for edit
    IStagedPage staged = page.Staged.CheckOut();
    IPageTemplate template = manager.GetTemplate("Inner");
    staged.SetTemplate(template.ID, "Emerald-Blue");
     
    BlogPosts bpControl = new BlogPosts();
    //get page again
    page = (ICmsPage)manager.GetPage(page.ID, true);
    page.Staged.AddControl("Content", control1);
     
    //get page once more
    page = (ICmsPage)manager.GetPage(page.ID, true);
    page.Staged.CheckIn();
    page.Publish();

    More information and samples on working with pages programmatically can be found in this webinar: Sitefinity API tips & tricks.
     
    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  9. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    09 Oct 2009
    Link to this post
    Hi Radoslav!
    You rocks! 
    It's working now! Now I will continue my upgrade work on Sitefinity =)
    Thank you!
Register for webinar
9 posts, 0 answered