Sunday, 8 February 2015

Office365 :Corporate Site Template App

A tribute to an old fellow, parting from Office365 world , a public facing Office 365 site like you never experience. Single click deployment.

What is corporate site template App?

It’s a simple provider hosted SharePoint app that will convert your SharePoint public facing site, or your publishing site to a responsive site.
Once you add the app to your SharePoint site it will copy some files (Master pages and page layouts) to the Master Page Gallery under a folder named Custom.

Note: Make sure that you don’t have a folder with the same name otherwise all the files with similar names within the custom folder will be overwritten.


In the below screenshot you can see the files copied to the custom folder

In addition to that the app will upload a new PublishingImageRenditions.xml file to the root folder of the Master Page Gallery.

The app will not only copy custom files to master page library but also will create some custom lists and pages in your SharePoint site.
Installation Steps

1. Create QueryPropertiesTemplate Document Library 
In your website create new document library and name it QueryPropertiesTemplate, upload this xml file to it.
2. Make sure that your page library have the required checkout before editing.
Go to your website update the page library versioning settings to allow checkout before edit

3. Add the app to your site using.

Add the app to your site and wait for the app to be successfully added and all the related SharePoint artifacts are created.

What are the App components?

Pages



Main template of the site and it consists of 4 different components:

  1. Header
    1. Site Logo
    2. Menu
    3. Search box
    4. Contact Number Icon
  2. Spotlight
  3. Article Roll-up
  4. Footer
    1. Social links
    2. Additional links
    3. Copyright Text.



Meet Our Team

Page list the current organization team member contact cards, it reads the information from the team member custom list which will be explained later in this document.

Contact Us 

Display page content as HTML and below it a location map read from the office location item in the configuration list.

FAQs Page

Read the FAQs from FAQs list, in the top area the user can filter by FAQ categories (stored in another list also created by the app)

Gallery Page

Image Gallery list all the images from a library, user can change the source image library by changing a configuration Item in the Configuration list.


Custom Lists


Configuration List

Created by the app to store the configuration values, below is the description:

Title
ConfigValue
Description
MainMenuTermSetId

Store the value of the navigation term set, Leave it blank in case of public facing website as Managed metadata navigation is not supported in Office365 Public Facing site.
HomePageRollupRenditionID
5
Points to the image rendition created by the app which is used in the home page article rollup component which is below the main home page spotlight.
HomePageSpotlightRenditionID
6
Points to the image rendition created by the app which is used in home page spotlight.
HomePageRollupSearchQuery
querytext='ContentType:"Article Page"'&SelectProperties
='Title,Comments,
PublishingImage,PATH'&rowlimit=7
Can be updated to filter the articles appear in the home page rollup. If you are not familiar with the SharePoint 2013 Search RESTful API please take a look at this link
CopyRight
Copy Right Text
Change this to your own footer copy right text
ContactNumber

Change this to your organization contact number.
OfficeCoordinates
24,54
Your office coordinate which is been displayed in Contact Us page.
TeamPageRenditionID
7
Points to the image rendition created by the app which is used in Team Member page.
GalleryRenditionID
8
Points to the image rendition created by the app which is used in Gallery page.
DefaultImageUrl
/Lists/TempImages/1.jpg
Default Image in case the content image is not added. Currently points to a temp image uploaded by the app.
SearchPage
/pages/searchresults.aspx
Search page URL
ImageGalleryListName
TempImages
Image Library contains the images displayed in the Gallery Page.

FAQs

Created by the app to store the FAQs items, below is the description:

Field
Type
Description
Title
Single Line of Text
The FAQ
FAQValue
HTML
FAQ body
FAQCategory
Lookup
Lookup to FAQ category list


FAQ Categories

Created by the app to store the FAQs items, below is the description:

Field
Type
Description
Title
Single Line of Text
FAQ Category value


Menu Items

Created by the app to store the Menu items, below is the description:

Field
Type
Description
Title
Single Line of Text
Link Text
SocialLink
URL
Link URL
Class
Single Line of Text
Class for Social links and Parent in Main Menu.
MenuContext
Single Line of Text
Represents where the item will be displayed i.e. FOOTER, MAIN, SOCIAL


Please note that if you are using managed navigation (not deploying to Office365 public facing site) the menu items with MAIN context are useless until you make sure that the configuration Item MainMenuTermSetId has empty configuration value.


Spotlight

Created by the app to store the home page spotlight items, below is the description:

Field
Type
Description
Title
Single Line of Text
Link Text
SpotlightDesc
Note
Spotlight item description in plain text format.
SpotlightLink
URL
URL for the spotlight item (internal/External)
SpotlightImage
URL
URL for the spotlight Image.


Team Members List

Created by the app to store the organization team items, below is the description:

Field
Type
Description
Title
Single Line of Text
Employee Name
TeamMemberImage
URL
Image for the team member.
Team Member Role
Single Line of Text
Team member role.
Team Member Desc
Note
Description for the team member role in plain text.
Team Member Email
Single Line of Text
Team member Email
Team Member Phone
Single Line of Text
Team member Phone
Team Member Facebook
URL
Team member Facebook Link
Team Member LinkedIn
URL
Team member Linkedin URL
Team Member Twitter
URL
Team member Twitter URL
Team Member GPlus
URL
Team member Google Plus URL



Temp Image List

This list is just a temporary Image list contains a set of images uploaded by the app


For a working live example to an Office 365 public site with the app installed on it please check 
insightme-public.sharepoint.com


To get the app, Please download the source code from msdn code gallery here


Thursday, 5 February 2015

Office365 Automation: Provision Lists & List items using App model

In this post I will explain in details how to provision Lists and list items using a Provider hosted app and a declarative XML files to define List Schema and Sample data items. This tutorial will use the App installed and uninstalled remote event receivers to do the task!

First what you need to have is:

  1. SharePoint online or Office365 subscription.
  2. Visual Studio.
  3. Windows Azure subscription.
  4. Sellerdashboard account 
What you need to do is:

  1. Create new SharePoint App project 
  2. Choose the app to be provider hosted and choose your target site
  3. Login  to your Office365
  4. Create a Folder Called ListDefinitions
  5. Under the folder create 2 XML files for 2 custom lists 
    1. CountryList.xml
    2. CityList.xml
  6. Enable the App remote event receivers for both installed and uninstalling events.
  7. As you can see I've created 2 methods in the AppEventReceiver.svc.cs to handle List Creation and deletion.
  8. Now to your Azure subscription we need to create a website to host our event receivers
  9. Download the publishing profile
  10. Create ClientId  for your app.


  11. Import your publishing profile
  12. Publish the app using the obtained Client key and secret

  13. Upload the app to your app catalog or simply run the SharePoint solution 

  14. Add the app
  15. Trust the app.
  16. wait for a while until the remote event receiver creates the two custom lists and add the sample data items to them.
  17. You can check the inserted data and the correct lookup column reference in the city list

You can download the code sample from here

Sunday, 1 February 2015

SharePoint 2013: Image Rendition location & automation

In this post I wont just list how and where Image rendition stored in SharePoint 2013 , I will provide a walk-through on how you can discover this on your own without relaying on Google Search or any other blog posts.

If you are not familiar with the "Image Rendition Feature" which is newly introduced in SharePoint 2013  please refer to Waldek's  excellent blog post here.

If you used image rendition before you will notice that the ID is not easily maintainable as It's a counter once you add a new item the ID is automatically given as the previous value+1.

another important thing to share that in SharePoint 2013 there are 2 different kinds of Image rendition , the predefined ones which you define by navigating to site settings ->Image rendition. The other kind is what I call "on the fly" which you refer to an image by width and height. {ImageUrl}?width=300&height=150

For the second type you can't update a specific picture's image rendition unless you already have a rendition predefined with the same dimensions.

To elaborate more in the below screenshot you can see an image rendered with width=300 and height =150  which is generated without predefined rendition.


Let's go back to the main point of the post which is how the image rendition is stored in the SP site collection.

If you have any  decompiler like ILSPY just copy the ISAPI folder from your Hive 15 folder to ILSPY folder ,load SharePoint assemblies in particular Microsoft.SharePoint.Publishing.dll , then in the search bar type rendition and wait for the results as shown below:


Select the ImageRenditionCollection and choose   SetRenditions Method


In this method you will find that the file been loaded and edited is located at the below path



from the above you can tell that the Rendition are stored in a single XML file under the masterpage folder.

As a conclusion to automate the creation of your predefined Image renditions you can add an xml file to a Module element and deploy the publishedImageRendition file to automate the creation of the image rendition instead of using the ImageRenditionCollection.Add Method in a feature activation code.
If you are using Office 365 you can either build a sandbox solution or refer to my previous post to use your App as module element to upload files to SharePoint using Remote event receiver.