Sharepoint Site Template - Custom .aspx pages - sharepoint

I am creating a site template in Sharepoint. I also have some custom .aspx page, that I want to deploy in Layouts\myDirectory. Using my site template I will create a Web (SPWeb) that should use the custom pages and reference them by an url of the form http://site/MyWeb/MyCustomPage.aspx. How do I integrate the pages in my custom template?

Pages stored in the Layouts folder are Application Pages and should always only be referenced through the _layouts virtual directory
If you want to reference the page as http://site/MyWeb/MyCustomPage.aspx then it should be a Site Page
A site page can be put inside a feature or directly inside a Site Definition (even thought I recommend that you only use the Site Definition to activate features). The way you provision the page is throught the Module & File elements see MSDN

A site template can only contain the contents of a single site/web. So you can't deploy files to the layouts folder using this technique.
However you can use site templates in combination with a solution package that copies your files. There is an example here. Deployment of the solution package will deploy your custom .aspx pages once. From then on they will be accessible to sites created by your site template.

Related

Sorry, this site can't be saved as a template. It contains apps that don't work in templates

I have tried to save the SharePoint communication site as a template that contains apps. I have faced the below error.
Sorry, this site can't be saved as a template. It contains apps that don't work in templates.
Please check social.technet.microsoft.com link for the same issue.
The above link suggests removing apps and saving the template of the site. But I will need a site template with apps. Can anyone suggest how to save SharePoint communication site as a template with apps?
Refer to this official article:
https://learn.microsoft.com/en-US/sharepoint/troubleshoot/sites/fails-saving-site-as-template
If the site contains apps that can't be saved as part of the template, it's necessary to remove any affected apps that are listed in the error message, and then save the site as a template.
If you want to use the app after you save the site as a template, you'll have to add it to the site again.
If you want to use the app in a new site based on template, you need to manually add it in the new site.

What is the use case for a "Mixed" ASPX+ Portal page template?

Reading this question regarding using portal engine vs. aspx, there is also the option for a "Mixed" template which the training defines as:
This page template is based on an ASPX page located in the path specified in the File name field. ASPX+ Portal page templates are based on an ASPX page with additional page components that enable the Design tab.
What isn't clear is what the use case is for this mixed template. When would you use this versus the other two?
Update
I read the following in the Developer Training materials:
Sometimes, you may need to combine ASPX page templates or external ASPX pages with
Portal Engine page templates on a single web site. When developing or maintaining a
web site built on ASPX page templates, you must manually modify the code of a page
every time you want to change its design. But you can add flexibility to ASPX templates
by defining areas that can be edited directly through the browser using the CMS
administration interface (similar to the Portal Engine development model).
This explains clearly that it is a true hybrid where you have both ASPX template and Portal Engine functionality, but it isn't clear what benefit you have by using this approach versus a Portal Engine template that utilizes widgets or web parts.
I'd say there is no "benefit" as such. You can use this mode e.g. when you are migrating existing ASPX web site to Kentico portal engine pages and replacing components (such as controls and web parts) one by one. When you finish the migration you can switch to portal engine mode. The goal was to provide this functionality for those who need it. It is recommended to use portal engine as you have complete control over the pages from CMS Desk.
The most common place I use them is when adding templates to a site using ASPX page templates, usually sites tend to have a content page, where I can swap out the controls (usually editable regions) with web part zones, then use that one template file to create multiple ASPX + Portal templates.
That way I can add a lot of new functionality into an existing site, without having to create half a dozen new .aspx templates.
I imagine it's also still useful for a new project where you want to keep your templates under source control, while utilizing the portal engine/web part functionality of Kentico.

what is difference between site definition and web template?

Yesterday in one interview they asked what is difference between site definition and web templates? Really I was confused. Can any one tell me the differences? I googled but not got the specific answer.
Site definition affects an entire site collection created from it.
Web template is site-scoped.
Site definitions consist of files stored on a front-end web server in folders under the \(14 hive)\TEMPLATE\SiteTemplates directory.
Web templates are stored in the database.
Web templates are based on existing sites, so they depend on the site definition used to create their base site.
More information: Site Types: WebTemplates and Site Definitions

Site Template and Master pages

I am a .net developer and want to learn SharePoint. Usualy we use MasterPages to have a constant layout for all or some of the pages. My confusion here is SharePoint uses Site Template and MasterPages which both sounds to do same thing. am I right?
thanks
MasterPages and Site templates are absolutelly different thing. Master page is usually layout of some pages. It's same like in ASP.NET.
In Sharepoint you can create some sites in site collection. These sites are created according to site template. When you creating (for example) team site, it's created according to team site template, which is stored in Sharepoint folder on file system. In site templates you can specify which features should be activated when site is created, which features should be activated on site collection scope etc. Also you can specify list, which should be created, modules... And also you can specify default master page which will be used on site.
You can find more informations on msdn

SharePoint Personalization With Application Pages

I am trying to implement personalization (WebPartManager and WebParts) on ASP.NET application deployed to SharePoint as application pages (Separate application and aspx pages deployed to _layouts).
I'd like to take advantage of SharePoint personalization provider, so I can just wire up the provider to WebPartManager in the ASP.NET application. However SharePoint seems to call SPRequest object to perform these tasks, and does not have a provider for personalization.
The second option I tried was to use SharePoint WebPartManager on these pages but it does not seem to work because application pages are not uploaded pages inside the SharePoint content database, so I receive errors when I try to add/personalize a webpart.
Does anyone know a clean way to utilize SharePoint personalization on application pages?
Normally, application pages are not tied to a specific site. And the webpart manager keeps the personalization values with the page in the site the page comes from.
You can probably accomplish what you are trying to do by using ASP.NET personalization. But then you have to use the ASp.NET personalization infrastructure which [I think] wants to use SQL Server by default.
Of course, the drawback to this is that you will have 2 personalization infrastructures implmented. This could mean deployment headaches.
Roger Williams
Franklin Laboratory
You may want to use page layouts with publishing pages instead of application pages.
Application Pages are ment to be shared across the Application in the Farm and doesnt support personalization. You need to deploy them as the Publishing pages to make use of the Personilization. You can try upload these files using features and as the Ghostable. So that you dont need to place them in the Pages Library you can have it in any web folder you want . For more information refer this link

Resources