Sladescross's Blog

Blogging about Sharepoint related stuff

Page Layout Setup Path Problem February 28, 2012

Filed under: Page Layout — sladescross @ 5:17 pm

http://www.insidesharepoint.net/post/2011/06/21/How-to-fix-renamed-page-layout-features.aspx

if ([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web) -eq $true)

{

$pubsite = new-object Microsoft.SharePoint.Publishing.PublishingSite($spsite);

$pubweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web);

$pageLayouts = $pubsite.GetPageLayouts($true);

$oldFile = $null;

$newFile = $null;

$nrOld = 0;

$nrNew = 0;

$pageLayouts | ForEach-Object {

$file = $_.ListItem.File;

if($file.Properties["vti_setuppath"] -eq $oldFilePath)

{

 

Page Layout Primer December 15, 2010

Filed under: Page Layout — sladescross @ 3:32 pm

http://avikercode.blogspot.com/2010/07/how-to-create-sharepoint-publishing.html

Point and click to custom page layout.

http://weblogs.asp.net/jimjackson/archive/2007/11/05/create-a-new-page-layout-in-sharepoint-2007-feature-based.aspx

Feature based approach to deploy custom page layout.

http://sharepointlogics.com/2009/02/content-type-page-layout-and-publishing.html

Publishing Page content type.

http://msdn.microsoft.com/en-us/library/aa981226(v=office.12).aspx

Custom field control.

http://msdn.microsoft.com/en-us/library/ms543497.aspx

Master pages and page layouts.

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/ed84256d-f525-48fe-8ebf-533a0876a09a/

I followed the steps from Patrick Tisseghems book ‘Inside MOSS2007′, which includes the following instructions:

  • Create and implement the following classes: CustomField, CustomFieldValue, CustomFieldControl. Sign them and deploy the assembly to the GAC.
  • Create a User Control Custom.ascx. Copy it to Controltemplates directory.
  • Create fldtypes_custom.xml and copy to 12\TEMPLATE\XML
  • Add <SafeControl /> entry to web.config
  • IISRESET
 

Page Layouts and Powershell December 6, 2010

Filed under: Page Layout,Page Layout Powershell — sladescross @ 4:49 pm

http://sharepointtales.wordpress.com/2010/04/27/creating-sharepoint-page-layouts-as-features-in-2010/

What we are looking for is something like: 

<File Path=”MyPageLayout.aspx” Url=”MyPageLayout.aspx” Type=”GhostableInLibrary”>
    <Property Name=”Title” Value=”My Page Layout”/>
    <Property Name=”ContentType” Value=”$Resources:cmscore, contenttype_pagelayout_name”/>
    <Property Name=”PublishingAssociatedContentType” Value=”#;MyContentType;[a really long id];#”/>
</File>

Ideally, we’d like some nice powerful mechanisms from within the Visual Studio IDE for generating this stuff. I’m working on that as part of a submission to the CKS:DEV team, but in the meantime we do have another solution. In 2010, you now have Powershell. And look what it can do for you… 

First, we need to be able to get the page layout in question from a supplied SPWeb and name.

function Get-SPPublishingPageLayout(
    [Microsoft.SharePoint.SPWeb] $web,
    [string] $name)
{
    $pubWeb = Get-SPPublishingWeb -web $web 
    return $pubWeb.GetAvailablePageLayouts() | ? { $_.Name -eq $name} 
}

Next, we need to format all those bits into the right structure:

function Get-XmlForPageLayout([string] $name)
{
  $layout = Get-SPPublishingPageLayout  -web (Get-SPWeb $siteurl) -name $name
  return (@”<File Path=”{0}” Url=”{0}” Type=”GhostableInLibrary”>
    <Property Name=”Title” Value=”{1}”/>
    <Property Name=”ContentType” Value=”$Resources:cmscore, contenttype_pagelayout_name”/>
    <Property Name=”PublishingAssociatedContentType” Value=”#;{2};{3};#”/>
</File>
“@ -f “PublishingModule\$name”, $layout.Title, $layout.AssociatedContentType.Name, $layout.AssociatedContentType.Id)

This now makes it really easy to get the format you need for your elements.xml file. All you need to do now is call this function:

$siteurl = “http://www.fabrikam.com”
Get-XmlForPageLayout  -name “homepage.aspx”

 

Page Layouts and Master Pages November 11, 2010

Filed under: Master Page,Page Layout — sladescross @ 12:43 pm

http://msdn.microsoft.com/en-us/library/ms543497.aspx

Overview.

http://www.codebanking.com/articles/sharepoint/customize-master-page.asp

The page layout contains all of the Content Controls that match the content placeholders from the master page file. For example, the matching content control from our sample master page content placeholder from above would look like this:
        Insert field controls, web part zones or HTML code here
 
Page layout content should be content that will change from page to page, for example:
  • Title, Author, Byline
  • Body Text
With the exception of the Registry tags, nothing can be outside of a content control in the page layout file! If you try to wrap HTML or add extra code outside of the content control, it will break the page.
SharePoint content is added to the content controls in a page layout in one of two ways, Field Controls or Web Part Zones.
Field Controls are content areas that map to columns in the Content Type. Field control placement is controlled in the page layout file and can’t be moved by the content editor through the web interface. They are ideal for situations where excerpts of content need to remain in a fixed location on a site. A field control looks similar to this:
Web Part Zones on the other hand allow content editors to add and move content around on the page. They work very similar to how they did in SharePoint 2003. The web part zone is specified in the page layout, and then the content editor can choose to add, remove or rearrange web parts within the specified zones. A web part zone looks similar to this:
Content Types are a new feature/concept of SharePoint 2007. They definitely warrant learning about and gaining an understanding of. A content type is a collection of settings that is applied to a particular category of content that can be reused multiple times. Through content types you can manage metadata and the behavior of a document or item type in a central, reusable way. Please refer to the following additional resources for a more in depth explanation of content types:
Columns from a content type are referenced through the field controls in the page layout. One content type can be reference by multiple page layouts, but a page layout can only reference one content type. This allows you to easily change the page layout of a page in a site without compromising the content since the content is controlled in the content type. The only restriction is to change the page layout to another page layout that is based on the same content type as the original
All of the components that contribute to the rendered SharePoint page is stored in silos… master page, page layout, page, content type and all the bits in between that link them together. To connect it all:
  • A Page is stored in a Pages library within a site.
  • The Page references a Content Type that helps populate the page with data. Content types are stored within a site.
  • A Page Layout is applied to the Page to control what content appears and where through the use of Field Controls and Web Part Zones. This is specified within the Content Controls in the Page Layout.
  • A Master Page is applied to the site to wrap on the look and feel and control content placement from the Page Layout through the use of Content Placeholders
 

Page Layout File Node Content Type Property Name November 10, 2010

Filed under: Page Layout,Page Layout Content Type Name — sladescross @ 3:27 pm

http://www.tech-archive.net/Archive/SharePoint/microsoft.public.sharepoint.portalserver/2007-01/msg00343.html

You can look up existing content type name in site settings -> site
content types. Select the publishing content type name you want to set
and specify it in-place of
$Resources:cmscore,contenttype_welcomepage_name.

The syntax “$Resource:…” is used for internationalization and you do
not have to use it, if you dont need it. The list of content
management resources is specified in cmscore.resx

2) SharePoint supports creation of content types dynamically through
onet.xml, but I havent looked into details. Please refer to MSDN.

Following is a startup URL:

http://msdn2.microsoft.com/en-us/library/ms474369.aspx

 

Creating A Page Layout Page the AC Way

Filed under: Page Layout,Publishing Associated Content Type — sladescross @ 2:58 pm

http://msdn.microsoft.com/en-us/library/dd164422(office.12).aspx

Creating Page Layouts: The Development Approach

As with the customization approach, the process of creating page layouts by using the development approach is almost identical to creating master pages. The only difference is that, with page layouts, you must tell SharePoint Server which content type the page layout is associated with.

Create another Feature (or reuse the previous Feature used to provision the master page) and, within the element manifest file, add the following markup to provision the page layout.

<?xml version=”1.0″ encoding=”utf-8″ ?>
<Elements xmlns=”http://schemas.microsoft.com/sharepoint/“>
<!– add page layout(s) –>
  <Module Url=”_catalogs/masterpage”
          RootWebOnly=”TRUE”>
    <File Url=”sampleLayout.aspx” IgnoreIfAlreadyExists=”TRUE” Type=”GhostableInLibrary”>
      <Property Name=”PublishingAssociatedContentType”
                Value=”;#Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC
                  3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#” />
      <Property Name=”PublishingPreviewImage”
                Value=”~SiteCollection/_catalogs/masterpage/Preview Images
                  /MSDN/sample.gif, ~SiteCollection/_catalogs/masterpage/Preview Images/MSDN/sample.gif” />
      <Property Name=”ContentType”
                Value=”$Resources:cmscore,contenttype_pagelayout_name;” />
      <Property Name=”Title”
                Value=”Sample page layout” />
      <Property Name=”MasterPageDescription”
                Value=”Sample page layout description.” />
    </File>
  </Module>

  <!– add preview image –>
  <Module Url=”_catalogs/masterpage/Preview Images/StructuredDev”
          Path=”LayoutFiles”
          RootWebOnly=”TRUE”>
    <File Url=”preview.gif” IgnoreIfAlreadyExists=”TRUE” Type=”GhostableInLibrary”>
      <Property Name=”Title”
                Value=”Sample preview image” />
      <Property Name=”MasterPageDescription”
                Value=”Sample preview image” />
    </File>
  </Module>
</Elements>

 

Creating A Page Layout Page November 4, 2010

Filed under: Page Layout — sladescross @ 8:59 pm

http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=71

Now we need to specify some properties for the Page Layout. These properties are identical to the kind of properties you would specify for a Page Layout in SharePoint 2007:
  • The Title of the file in SharePoint
    In our case, the file itself has a URL of MyCustomPageLayout.aspx, but we can also give the page a Title that will show up when the Page Layout is being selected by the content author, such as “My Custom Page Layout”.
  • The Content Type
    All Page Layouts must inherit from the “Page Layout” content type (which we add using a Resource file value.)
  • A Publishing Preview Image
    The Publishing Preview Image is the image that shows up when a user picks that Page Layout from the Page Layout picker while they’re creating a new page. In this example, we’ll just point to the Article Page’s preview image.
  • The Publishing Associated Content Type
    This is the Content Type that the Page Layout is representing, such as an “Article Page”, “Welcome Page”, etc. The value is a string representing a Lookup value that’s a combination of the name of the Content Type and its unique identifier.

Our new File node will look like this:

<File Path=”masterpage\MyCustomPageLayout.aspx” Url=”MyCustomPageLayout.aspx” Type=”GhostableInLibrary”>
      <Property Name=”Title” Value=”My Custom Page Layout” />
      <Property Name=”ContentType” Value=”$Resources:cmscore,contenttype_pagelayout_name;” />
      <Property Name=”PublishingPreviewImage” Value=”~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/CustomPageLayout.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/CustomPageLayout.png” />
      <Property Name=”PublishingAssociatedContentType” Value=”;#$Resources:cmscore,contenttype_articlepage_name;;
#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#”
/>
</File>

 

Provisioning Page Layout Pages November 3, 2010

Filed under: Page Layout,Provision — sladescross @ 9:18 pm

http://octavievanhaaften.wordpress.com/2010/08/17/provisioning-publishing-site-with-custom-content-types-and-page-layouts/

Provision using the Sharepoint Project Item type Module.

2 special lines of code I want to point out:

line 8: PublishingWeb.GetPagesListName

line 18: GetLocalizedString()

Both return the correct name of the Pages and Documents library no matter what language is used. Especially the Documents library was hard to find. Do not mistake this library with Shared Documents (that’s the team site version). To get the right name I was googling around. I found a post, but this was the wrong resource file and name. So, I had to find it myself in the SharePoint Root folder\Resources. And there she was: cmscore.resx. :p Gotcha! The rest was easy….

http://blog.beckybertram.com/Lists/Posts/Post.aspx?ID=71

Provision using Visual Studio Sharepoint Project Items.

and copy layout from Sharepoint Designer removing

meta:webpartpageexpansion=”full” meta:progid=”SharePoint.WebPartPage.Document”
 

Sharepoint Master Pages and Style Sheets August 13, 2010

Filed under: CSS,Master Page,Page Layout,Sharepoint Master Page,Style Sheet — sladescross @ 4:37 pm

http://www.cleverworkarounds.com/2007/10/08/sharepoint-branding-how-css-works-with-master-pages-part-1/

Master Page + (Content) Page Layout = Page.

 

Create A Publishing Page Layout March 8, 2010

Filed under: Page Layout,Sharepoint — sladescross @ 5:13 pm

http://office.microsoft.com/en-us/sharepointdesigner/HA101741281033.aspx

http://stackoverflow.com/questions/630676/how-to-change-page-layout-in-sharepoint-wss-site

WSS doesn’t support page layouts (as they are known in MOSS) as they’re installed as part of the web publishing feature in MOSS.

WSS pages are instanced off the aspx page templates defined in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\SMARTPGS.

These are based off the site master page and are (effectively) standard aspx pages. You can’t change the template that’s used – the page exists on the site once it’s created.

 

 
Follow

Get every new post delivered to your Inbox.

Join 63 other followers