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

Forums / Developing with Sitefinity / Posting news, events and blogs from outside admin

Posting news, events and blogs from outside admin

12 posts, 0 answered
  1. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    17 Feb 2009
    Link to this post
    On our site it would helpful if users could post news, events and blog without having to go into the admin site.

    Is there a simple way to put the input forms for those modules onto regular sitefinity pages? Or would custom forms using the API be needed? If so, where is the best place to find this information. All of the information I've found dealing with those modules all involves changing the functionality on the admin forms.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Feb 2009
    Link to this post
    Hello derek,

    Thank you for using our services.

    You can create some user controls for that. In this case you need to use Sitefinity's API

    Here is an example below:


    <asp:Label ID="label1" runat="server" Text="Title" /><br /> 
    <asp:TextBox ID="Title1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="TEST" onclick="Button1_Click" /> 


            ContentManager contentManager = new ContentManager("News"); 
            // create an empty content 
            IContent newContent = contentManager.CreateContent("text/html"); 
            newContent.Content = "Here is my custom content here"
            // set meta keys for the content item 
            newContent.SetMetaData("Title", Title1.Text); 
            newContent.SetMetaData("Author""Admin"); 
            newContent.SetMetaData("Description""Some description goes here."); 
            DateTime newTime = DateTime.Today; 
            newContent.SetMetaData("Publication_Date", newTime); 
            newContent.SetMetaData("Expiration_Date", newTime.AddDays(30));  
     
            //save the content 
            contentManager.SaveContent(newContent);  

    Just to let you know for blogs you can use Live writer. Check out MetaWeblogHandler Class.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    25 Feb 2009
    Link to this post
    You recommend using the content manager for both News and Events. Is this better than using the EventsManager and NewsManager?

    Would we lose any event or news functionality by treating them as standard content?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Feb 2009
    Link to this post
    Hi derek,

    In the example ContentManager uses specified provider when working with data. News, Events and Blogs are GenericContent based modules. All methods used by NewsManager, EventsManager and BlogsManager are methods of the ContentManager class. 

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    25 Feb 2009
    Link to this post
    Ah, yes I see now.

    I can see from the meta fields in the web.config that category is avaiable for news and events via the setMetaData() method.

    I.e:

    newContent.SetMetaData("Category", "Some Category");

    I don't however see Tags listed at meta information, how would you get a tag onto the Content object?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Feb 2009
    Link to this post
    Hi derek,

    The ContentManager class includes methods for the following tasks:  Creating, Modifying, Finding and Deleting tags.

    Example:

    ContentManager contentManager = new ContentManager("News"); 
    // get all tags 
    IList listOfAllTags = contentManager.GetTags(); 
    // check whether we have created tags 
    if (listOfAllTags.Count > 0) 
        foreach(ITag tag in listOfAllTags) 
           Response.Write(tag.TagName); 
    }  

    More information could be gathered form our developer manual. I hope this helps.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. derek
    derek avatar
    37 posts
    Registered:
    15 Jun 2007
    26 Feb 2009
    Link to this post
    Sorry if my question wasn't clear enough. I already know how to retrieve and create Tags, but I can't figure out how to relate the tag to the content.

    When I create news or events I need to tag that piece of content so that it can be filtered properly.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    26 Feb 2009
    Link to this post
    Hi derek,

    Here is the way to add Tags to your content item.

    List<string> tags = new List<string>(); 
    tags.Add("my_tag"); 
    tags.Add("another_tag"); 
    contentManager.SaveTags(newContent.ID, tags); 


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    13 Apr 2011
    Link to this post
    This adds tags to generic content, how could I add them to a blog post? The above works to apply tags to a posting, but they are not listed with the tags under the blog.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Apr 2011
    Link to this post
    Hello Elizabeth,

    You need to assign the tag to your content item.

               Manager.SaveTags(cnt.ID, this.SelectedTags);
               this.Manager.SaveContent(cnt);

    This adds tag to content - cnt and it should be displayed on the public side.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

  11. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    14 Apr 2011
    Link to this post
    The code that I am using is below. It does associate the tag with the blog posing, but the tag is not listed under the Blog tags, but with the Generic Content tags:


    ContentManager CM = new ContentManager();
                           
    List<string> tags = new List<string>();
    tags.Add(school);
                          
    CM.SaveTags(postContent.ID, tags);
    CM.SaveContent(postContent);
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Apr 2011
    Link to this post
    Hello Elizabeth,

    You need ti set the provider to the ContentManager. Currently you are using the Generic_Content provider instead of block. Please add the Blogs provider as  a  parameter of the ContentManager.

    All the best,
    Ivan Dimitrov
    the Telerik team

Register for webinar
12 posts, 0 answered