Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm playing around with the Create Design Package feature, and to be honest it's far more than we need for our features.

We have certain Page Layouts that need to be deployed on certain site collections and then custom pages that need to inherit that Page Layout. We're trying to figure out how to do that all programmatically with SharePoint 2013, now that the .aspx files are generated dynamically for you.

Is there some kind of code we would need to add to the feature to get it published as a Page Layout?

share|improve this question
add comment

3 Answers

Wael actually had the correct answer. Here is the gist of what needs to be done for packaging a Page Layout:

Using Visual Studio, you can create a new Module and add your page layout to that file. Then, in the elements.xml file for that Module, here is what I typically use:

<Module Name="PageLayouts" Url="_catalogs/masterpage">
    <File Path="PageLayouts\Dashboard.aspx" Url="Site.Dashboard.aspx" Type="GhostableInLibrary" Level="Published" ReplaceContent="TRUE">

        <!-- Page Layout Options -->
        <Property Name="ContentTypeId" Value="0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE81100B432574477BA904292DFD58D26CE0E24" />
        <Property Name="UIVersion" Value="15" />
        <Property Name="ContentType" Value="Page Layout" />
        <Property Name="_ModerationStatus" Value="0" />
        <Property Name="FSObjType" Value="0" />
        <Property Name="PublishingAssociatedContentType" Value=";#Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#" />

        <!-- Specific Options -->
        <Property Name="Title" Value="Dashboard" />
        <Property Name="MasterPageDescription" Value="The dashboard layout for the site." />

    </File>
</Module>

Then you'll have to create a feature and add the module to that feature. Make sure the feature is at least scoped to the site collection (it cannot be scoped to an individual web site). Activate the feature on your site collection and you should see your new page layout in the master page and page layout gallery.

share|improve this answer
    
This is how I've found up doing it. It's EXTREMELY important to note that you'll need to export and use the Elements.xml file from the Design Package creator if you place webparts on your page layout. The ASPX files themselves do not hold any webpart information, only the XML file does. –  EHorodyski Aug 30 '13 at 18:06
    
thanks man, you saved my day. –  AmitKB Mar 16 at 15:47
add comment

I've found the Create Design Package to be more trouble than it's worth. It doesn't actually provide you with a feature that you can activate/deactivate, as far as I can tell.

For the site collection where you build your page layout, you just use the Design Manager to "Create Page Layout". You then edit the html file until it is what you want, then publish and approve that page layout, and then you can script up adding it as a page layout on whatever pages you need, just as you would in 2010.

For any other site collections you might have, you can just copy and paste the aspx file into their Master Page Galleries (which can be scripted), and then do the same as above.

Hopefully this makes sense... I am going through this process currently myself, so feel free to take this with a grain of salt.

share|improve this answer
    
I'm still hoping there is a better approach. The way SharePoint does it with the .WSP it creates I believe I would need to have the .aspx file generated from Design Manager, and I can't write code to add it to the gallery as an HTML file then publish it so it would automatically generate the .ASPX page for me. –  EHorodyski Mar 19 '13 at 15:34
    
hmm... and why can't you just copy and paste the actual aspx file? –  Nacht Mar 20 '13 at 0:14
    
Because everytime I'd need to go in and make an edit to the Page Layout I'd have to go to my dev machine, edit the HTML file on the file system and then replace the edited HTML file and the re-generated ASPX file in my project. –  EHorodyski Mar 20 '13 at 15:12
    
Hmm... That sounds like the standard practise to me. Isn't that the point of a DEV machine? Unless I'm totally missing something here... –  Nacht Mar 20 '13 at 22:07
    
It is, but it's much more annoying to have to keep going back and re-adding files to my SharePoint solution everytime I want to make a minor change to a page layout then editing files inside a solution and deploying it. –  EHorodyski Mar 21 '13 at 15:07
show 2 more comments

I've been through this.

See this blog : http://www.estruyf.be/blog/how-to-provision-your-design-files-in-sharepoint-2013/

hope this will help ! ;)

share|improve this answer
    
Can you detail the answer instead of linking to a blog, if anything happens to the blog, the answer is lost. –  PirateEric May 14 '13 at 3:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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