views:

480

answers:

2

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?

+1  A: 

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.

Alex Angas
My problem is not with copying the aspx file to the layouts directory. What I don't understand is how to reference them in the elements.xml file for the pages feature that will be used by the site template.
iulianchira
+3  A: 

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

Per Jakobsen
These Site Pages, do they have to be web part pages or they can be simple asp.net pages with code-behind and user controls?
iulianchira
They can be both, just as long as the DLL is available to SHarePoint, either in the BIN folder or the GAC.
Colin
Think of the "pages" as files, as Per says they are provisioned through a module in the element.xml file in the feature (+1)
Johan Leino