How to: SharePoint Online Branding & News Center using Visual Studo Part 1 of 4

This “How To series” will be about how to create a News center in SharePoint Online, and as always i will be very detailed. To be more specific, this is what i will guide you through.

Part 1: Add a custom master page to enable branding

Part 2: Create the news page library with all content types that are needed.

Part 3: Create a news flow web part to be used in both the Start Page and the Archive.

Part 4. How to deploy and set this up in SP Online.

You can download this project from GitHub right here.

Before we start you need to have the fallowing:

  • A development environment with SharePoint 2013 and Visual Studio 2012 (I have not tested VS 2013)
  • Create a Web Application called OnlineNewsTest or similar and a top site called Portal.
  • Create a sub site to Portal called News Center

OBS! Make sure you have time, this will take some time and if you stress you most probably will make mistakes.

  1.  Open Visual Studio and Create a new Project that you call “SharePointOnlineNews”.
  2. Choose SharePoint 2013 – Empty Project (See image under)
  3. Screen Shot 2013-11-03 at 15.36.36
  4. In the next step choose “Deploy as sandbox solution” (To do this online you have to choose sandbox as you cant manage farm solutions) and choose your new Portal site (See image)
  5. Screen Shot 2013-11-03 at 16.14.17
  6. Now lets start by adding a custom master page width a “link” to a custom CSS. (You will need this to add some style to you news)
  7. In your project add a folder called FeaturedElements and in that folder you add a new Module (Right click and Add – new item.) Call the module “MasterPages”
  8. Under Featured Elements create another Module Called “Style Library” (Use exact name)
  9. Your project should look like this now.
  10. Screen Shot 2013-11-03 at 16.38.12
  11. Fold down Style Library and you will find a sample.txt, delete it and then right click on Style Library and create the following Folders. (The first folder should have the same name as your project)
  12. Screen Shot 2013-11-03 at 16.49.29
  13. Now on your Styles folder click add – new item and choose a Style Sheet, you find it under Web. Call it “custom.css”.
  14. In your custom css add the following so that we can see that every thing is working later. It gives your site a very sexy background color 😉
  15. Now, open your SharePoint site in a browser and go to Settings -> Site Settings -> Master pages and page layouts and in there download a copy of seattle.master. Rename the master to Your project name or similar. (My name is MyOnline.master)
  16. Place the MyOnline.master in your MasterPages module by right click on the module and choose Open Folder in File Explorer.
  17. Now in your project you have to click Show All Files in the header of the Solution Explorer. Then in When you Look in your MasterPages you will see your new master. Right click on the master and choose include in project.
  18. To include your custom.css in your master, open the master and find (SharePoint:CssRegistration Name=”Themable/corev15.css” runat=”server”) and just under it add the following css registration. You may have to change the namespace to how your project look if you have used different names than i have. (The After=”corev15.css” tells SP that your Style will load after SharePoints style.)
  19. Open the elements.xml under MasterPages and replace the content with this. If your master has an other name then mine then just change it. (It explains where the msater will be put in SharePoint)
  20. Now go to Features and you will see a Feature 1, rename it to “Activate.Branding”. Open the Feature and set Scope: Site. Make sure MasterPages and Style Library is included.
  21. Right click on the feature and click Add Event receiver. The file will open…
  22. Under “public class ActivateEventReceiver : SPFeatureReceiver” replace every thing with the following. You may have to change the master name… (This code will activate the master on your site and make sure Publishing is turned on.)
  23. If you have done every thing “by the book” you should now be able to right click on the project and take Deploy. You should get a very awesome lime-green background color. 🙂
  24. Your project should look like this now.
  25. Screen Shot 2013-11-03 at 17.48.06

Next up is Part 2 where we look at the news setup.

Leave a Reply

Your email address will not be published. Required fields are marked *