📜 ⬆️ ⬇️

SharePoint Foundation Corporate Site: Some Practical Tips

Good day, dear users of Habrahabr. I want to share with you the experience of creating a corporate site on the platform of Microsoft SharePoint Foundation 2010 (hereinafter - SPF). Recently, a release of a new version of the platform - SharePoint 2013 - has taken place, but I think this article will be relevant to it in many respects. I will not describe here the advantages and disadvantages of SharePoint as a site content management system. The purpose of this article is to show how relatively quickly and inexpensively by labor costs you can develop an organization’s website on this free platform. I hope for some of you this experience will be useful.

So let's get started. First of all, why was SPF chosen as the platform for the site, and not SharePoint Server (hereinafter referred to as SPS)? In accordance with the licensing policy of Microsoft for Internet scenarios, when access to corporate resources through SPS receives an unlimited number of anonymous users, you need to purchase a SharePoint Server for Internet Sites license. SPF is free and this is the main argument.

But, choosing SPF, we lose part of the functional content management system of the site, which is available in SPS in full. Mainly, these are additional corporate site templates and the ability to publish content. Corporate site templates speak for themselves and allow you to create a site based on a standard template. The publication feature allows the use of special content types of publications, lists and document libraries, web parts, master pages and page layouts. Together with the functionality of centralized management of master pages and inheritance of their child sites, site navigation control and the function of blocking certain site pages for anonymous users, the ability to publish provides the infrastructure of the site content management system. In the SPF, we have to do it by other means.

There is a popular opinion that a good corporate SharePoint site is a site that does not look like a SharePoint site. In order to achieve this effect, it is better to abandon the use of standard master page templates and SharePoint page layouts and replace them with your own. The first step is to create a master page of the site with branding in a corporate style. The easiest way is to start with a master page template with a minimum of ASP.NET/SharePoint controls and layout, such as starter.master , for example. Many for this purpose also use this guide to create a minimal.master master page. For site branding, you will need to override the standard CSS styles defined in the corev4.css, forms.css, etc. files. New style files can be placed in the SharePoint highway or a specially created folder in the site hierarchy. Branding can also be done using the SharePoint theme functionality by creating a theme in Microsoft Office Power Point or Microsoft Theme Builder and adding it to the site collection. Depending on the design, it often makes sense for the main page of the site to create a separate master page without the Quick Launch navigation bar or the top link bar.
')
If the structure of the corporate site is such that the top-level site has many affiliated sites, then it is necessary to correctly approach the issue of distributing updates of the main master page to subsidiary sites. As noted earlier, the SPF does not have the functionality to centrally manage the master pages of subsites. Of course, you can do it manually by copying the file of the updated master page to the collection of master pages of each of the sites, but this, to put it mildly, is inconvenient. It is more logical to wrap the main master page into an opportunity and install it with the help of a solution. Here is an example of the configuration files for this feature:
<Feature Id="23E27B3A-120C-3259-02DA-103CC45179BB" Title="Site Master Page" Scope="Site" Version="1.0.0.0" Hidden="FALSE" DefaultResourceFile="core" xmlns="http://schemas.microsoft.com/sharepoint/" Description="This feature deploys the site master page"> <ElementManifests> <ElementManifest Location="elements.xml" /> <ElementFile Location="MasterPages\sitemasterpage.master" /> </ElementManifests> </Feature> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="SiteMasterPage" Url="_catalogs/masterpage" Path="MasterPages" RootWebOnly="FALSE"> <File Url="sitemasterpage.master" Type="GhostableInLibrary" /> </Module> </Elements> 

The RootWebOnly = “FALSE” attribute indicates that the master page will be set in the collection of master pages of all sites of the family, and the attribute = = “GhostableInLibrary” means that all masters installed in this way will refer to one master page file located in the folder in the highways, so any changes in this file will be reflected in all sites.

Talk about site navigation. Unlike SPS, in SPF there is no possibility to create a hierarchical multi-level menu in the top link bar of the site navigation through the standard site administration page. But this can be done programmatically, for example, with the help of a simple PowerShell script:
 [System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"); $url = "http://site" $site = new-object Microsoft.SharePoint.SPSite $url; $web = $site.OpenWeb() $topnav = $web.Navigation.TopNavigationBar while ($topnav.Count -gt 0) { $topnav.Delete($topnav[0])} $node1 = new-object Microsoft.SharePoint.Navigation.SPNavigationNode -argumentlist @(" ", "/company", $False) $node1 = $topnav.AddAsLast($node1) $node2 = new-object Microsoft.SharePoint.Navigation.SPNavigationNode -argumentlist @("", "/company/pages/history.aspx", $True) $node2 = $node1.Children.AddAsLast($node2) $node3 = new-object Microsoft.SharePoint.Navigation.SPNavigationNode -argumentlist @("", "/company/events", $False) $node3 = $node1.Children.AddAsLast($node3) $node4 = new-object Microsoft.SharePoint.Navigation.SPNavigationNode -argumentlist @("", "/company/events/Lists/news", $False) $node4 = $node3.Children.AddAsLast($node4) 

For the quick launch menu, you can create two levels of hierarchy using the site administration page. If this is not enough, you can likewise create a navigation structure with a script.

As noted earlier, in SPS, the ability to publish creates an infrastructure for managing site content. Among other things, it allows you to store content in special libraries of documents “Pages” (Pages), for which the options of approving and storing a certain number of main and intermediate versions of content are included. In SPF, we can reproduce this functionality by creating the document libraries "Pages" manually and adjusting the properties and versioning of content for them in the properties. If other lists and document libraries are used to store content on the site, they can be configured in the same way.

The ability to publish to the SPS carries with it special types of content, for example, the “Article Page”. With their help, it is relatively easy to create new site content in the Pages document libraries of the SPS, the content is placed on the page in special publishing controls. In SPF, for this purpose, you can use the web part page, add the Content Editor web part to it, place the content in this Web Part, and place the page in the previously created document library “Pages”. If it is necessary to store HTML content in the elements of the list, then a “Multiline text” type field with the “Advanced Formatted Text” option is suitable for this.

When creating a site on SharePoint, it is difficult to do without customizing the standard web parts of list views like XsltListViewWebPart. Their architecture is rather peculiar, and if serious customization of a large number of such web parts is required, for example, with a change in XSLT rendering templates, you can eat a lot of glass on it. Faced with this task, for myself I made a choice to write my universal (for my purposes) web part, which, using the VIEW scheme specified in XML, retrieves data from the specified list / library of documents and imposes on them a simple XSLT template, which usually spelled in 5 minutes. As they say, feel the difference:
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="webparts.xsltlistviewwebpart"> <xsl:param name="ListUrl"/> <xsl:output method="html"/> <xsl:template match="rows"> <div id="news"> <div class="page_title" style="margin-top:7px !important; margin-bottom: 10px;"> <span> </span> </div> <table width="100%" border="0" cellspacing="0" cellpadding="3" class="ms-listviewtable"> <tbody> <xsl:for-each select="row"> <tr> <td style="vertical-align:top;"> <span class="date_text" style="display:inline-block;"> <xsl:value-of select="ext:Frmt_Date_Time(PublishDate, 'dd MMMM yyyy')"/> </span> </td> <td style="vertical-align:top;"> <a class="title_item" style="font-size: 10pt;"> <xsl:attribute name="href">javascript:</xsl:attribute> <xsl:attribute name="onclick">javascript: window.location.href='<xsl:value-of select="concat($ListUrl,concat('/DispForm.aspx?ID=',ID))" disable-output-escaping="yes"/>&Source=' + escape(window.location.href);</xsl:attribute> <xsl:value-of select="Title" disable-output-escaping="yes"/> </a> </td> </tr> </xsl:for-each> </tbody> </table> </div> </xsl:template> </xsl:stylesheet> 

Another important issue faced by the SPF website developer is to somehow deny access to certain pages of the site for anonymous users, for example, to application system pages accessible via / _layouts /, or service views of lists and libraries documents. In SPS, on sites created from the publishing portal template (publishing portal), the Blocking for Site Collection feature (ViewFormPagesLockDown) is used, which uses the blocking function of the system pages of the site for anonymous users. In SPF, this possibility is absent, and the most logical solution, in my opinion, is to create your own http module to analyze and block http requests to certain pages and then redirect to the page with information on access prohibition. The URL of the forbidden pages is convenient to set in the config of the web application of the site, for example, in this form:
 <SecuritySettings> <Extensions> <res ext=".aspx" /> <res ext=".html" /> <res ext=".htm" /> </Extensions> <Allowed> <res url="*/_layouts/searchresults.aspx*" /> </Allowed> <Denied> <res url="*/_forms/*" /> <res url="*/_layouts/*" /> <res url="*/_catalogs/*" /> <res url="*/_controltemplates/*" /> <res url="*/_cts/*" /> <res url="*/_private/*" /> <res url="*/_login/default.aspx*" /> <res url="*/m/default.aspx*" /> <res url="*/approval.aspx*" /> <res url="*/latestreports.aspx*" /> <res url="*/personalviews.aspx*" /> <res url="*/last2weeks.aspx*" /> <res url="*/allitems.aspx*" /> </Denied> </SecuritySettings> 

Adherents of search engine optimization of site content for search engines using meta tags are likely to be puzzled by the way in which you can create such tags for dynamic pages of the site, such as forms for viewing list items and document libraries (DispForm.aspx). In my case, I solved this question as follows:

 <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <Control Id="AdditionalPageHead" Sequence="50" ControlClass="MetaTagGenerator" ControlAssembly="MetaTagGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=18bdc3dfdc022d0b" /> </Elements> 


As a result, in the process of rendering the page of the form of viewing a list item or document library for which the keyword substitution field is filled, the corresponding meta-tags are placed on the page.

And finally, a few words about the functionality of site search in SPF. Standard search prompts to select a search area. On the corporate site, to my mind, such settings only hinder the user, since it usually requires searching through all the content. Therefore, I recommend to save the user from this choice by a little customization. To do this, do the following:

In this case, when sending a search request, the ORE.js system script in the_SubmitSearchRedirect function, without finding the list of SearchScope search areas in the markup, does not set the search area parameter, which will be perceived by the search service as a search on all sites in the site collection.

Source: https://habr.com/ru/post/163665/


All Articles