0

I am new in sharepoint, and I would like to build a news section for our intranet website. I thought about using the Publishing Portal, to make less flexible to the writer, so the content will be arranged following a layout. And I would like to present this Pages in a list. How can I build a list of sites of type Publishing Portal ?

0

You can achieve this in two ways

  1. If you choose a site with publishing feature activated (you don't need a publishing site) you could have a list with an Event Receiver so that when you add an item in that list a new publishing page is created with a customized layout as you state in your question.
  2. Another way is to have or not a publishing site. In that site you have a Custom List called News. Then you create a ASPX Page NewsDetails that receive the id of the item by querystring and you populate data in that page from the item of the News List.

Feel free to ask if you have any doubt

UPDATED

Try the following code taken from Technet to create the publishing page if you consider this is a better approach:

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.Publishing;

namespace CreatingPublishingPageWithEventHandler.EventReceiver1
{
  /// <summary>
  /// List Item Events
  /// </summary>
  public class CreatingPublishingPageEventReceiver : SPItemEventReceiver
  {
    /// <summary>
    /// An item was added.
    /// </summary>
    public override void ItemAdded(SPItemEventProperties properties)
    {
      base.ItemAdded(properties);
      SPSecurity.RunWithElevatedPrivileges(delegate
      {
        using (SPSite site = new SPSite("http://kfc1/sites/FirstTestSite"))
        {
          using(SPWeb web=site.AllWebs["publishingsite"])
         {
            PublishingWeb pbWeb = PublishingWeb.GetPublishingWeb(web);
            SPContentType contentType = web.Site.RootWeb.GetListFromUrl("Lists/Announcements/AllItems.aspx").ContentTypes[0];
            PageLayout layout=pbWeb.GetAvailablePageLayouts()[0];
            PublishingPage page = pbWeb.GetPublishingPages().Add("PublishingPageDemo.aspx", layout);
            page.Title = properties.ListItem["Title"].ToString();
            page.ListItem[FieldId.PublishingPageContent] = properties.ListItem["Body"].ToString();
            page.Update();
          }
        }
      });

    }

  }
}
  • Thanks for the help, @Alvmad. In 1., create a list with an event receiver, but I didn't understand the content of this list. 2. I made something very similar to this one: 1. created an announcement list, when I clicked on it, I got the id by qyerystring, and later on get it's hidden content and programatically showed the user the new user interface pre-formatted. (But I tought that there is a better approach, when I saw this publishing portal) – Tito Sep 19 '13 at 19:57
  • In case 1 you can have a custom list with title (single line text) and Description (Enhanced rich text). Or you can use Announcements list. Check the updated answer – Alvmad Sep 20 '13 at 5:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.