Adding web page to blank sharepoint site definition - sharepoint

I am totally new to Sharepoint (2007) so please bear with me. I would like to automatically create aspx pages when a new site is created. These pages will be linked to through tabs which will be defined by a master page. I do not have a custom site definition and was planning to apply feature stapling to the out of the box blank site definition.
Through my research, I think you can create a web part page and turn this into a feature. I can then staple this to the blank site definition. The problem is I haven't found any information on how to do this. So the two questions I have are:
How do I create a feature that is just an aspx page?
How do I staple this feature to a blank site definition?
I found one person asking the same question here: How to add a web part page to a site definition?
I read the first response but it sort of goes over my head and I don't know if it really answers my question.
Thanks so much!

The answer to your first question depends on whether you mean application pages or content pages. They each have their advantages: application pages are good in that they can run custom server-side code, and content pages are nice because (for example) they can be customized by users, but by default are restricted in what kind of code can be run.
For a pretty good discussion on the differences between the two types in capabilities and restrictions, check out the Windows SharePoint Services SDK and look at the topics called "Application _layouts page type" and "Content page type."
As for stapling, it's pretty easy and more flexible than adding new features to a site definition's onet.xml file. This article seems a pretty good overview of the alternatives. You might want to make a copy of the blank site definition, rename it, and then use that one in your work, though.
Features with content pages
You'll need three types of things for this:
A feature.xml file -- just the boilerplate stuff that refers to the element manifest.
A page template -- this could be the entire aspx page itself, or it could be (for example) a shell of a web part page with WebPartZones defined but no actual web parts (yet).
The element manifest file which refers to your page templates and defines any web parts that should be provisioned as part of activation of your feature.
Your feature's folder structure would look something like this:
12
+-- TEMPLATES
+-- FEATURES
+-- YourFeature
+-- PageTemplates
| +-- Page.aspx (simple aspx page)
| +-- WebPartPage.aspx (still simple, but with WebPartZones)
+-- feature.xml
+-- elements.xml
Feature.xml:
<Feature
Id="CFF117BC-9685-4a7b-88D0-523D9DAD21F0"
Title="Custom Pages Feature"
Scope="Web"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
Elements.xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Path="PageTemplates" Url="Pages" >
<File Url="Page.aspx" Type="Ghostable" />
<File Url="WebPartPage.aspx" Name="WebPartPage.aspx" Type="Ghostable" >
<AllUsersWebPart WebPartZoneID="Left" WebPartOrder="0">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<Title>Some content that you want to provision with the feature</Title>
<FrameType>TitleBarOnly</FrameType>
<cewp:Content>
Hello world.
</cewp:Content>
</WebPart>
]]>
</AllUsersWebPart>
</File>
</Module>
</Elements>
Page.aspx
<%# Page MasterPageFile="~masterurl/default.master"
meta:progid="SharePoint.WebPartPage.Document" %>
<asp:Content runat="server" ContentPlaceHolderID="PlaceHolderMain">
Hello World
</asp:Content>
WebPartPage.aspx
<%# Page Language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>
<%# Register Tagprefix="WebPartPages"
Namespace="Microsoft.SharePoint.WebPartPages"
Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ID="main" runat="server" ContentPlaceHolderID="PlaceHolderMain" >
<table width="100%">
<tr>
<td valign="top" style="width:50%">
<WebPartPages:WebPartZone ID="Left" runat="server"
FrameType="TitleBarOnly" Title="Left Web Part Zone" />
</td>
<td valign="top" style="width:50%">
<WebPartPages:WebPartZone ID="Right" runat="server"
FrameType="TitleBarOnly" Title="Right Web Part Zone" />
</td>
</tr>
</table>
</asp:Content>
If you configure your feature in that way, you should be able to deploy site content pages within that structure.
Also, I highly recommend Ted Pattison's Inside Windows SharePoint Services book. It covers this topic in much detail, including the important security aspects of site content pages. It's easily worth the purchase price.

Related

SharePoint Link with QueryString Parameters

The task is to migrate classic ASP functionality to SharePoint Server 2013.
On the ASP page, a certain link is visible only if the authenticated user's password can be retrieved from a database. The link looks similar to:
<a target="_blank" href="https://www.someurl.com/secure/login.php?username=<%=strUserName%>&password=<%=rsOpenOrders("CL_password")%>" onmouseover="self.status=' '; return true;">
<img border="0" src="somelogo.gif" width="267" height="80" /></a>
I'm new to SharePoint, and I would appreciate your help (conceptual and code snippet) in solving this problem.
I understand that writing "code behind" is not highly encouraged with SharePoint pages and web parts.
So, what's the best alternative to be able to use the authenticated username value in building the first querystring parameter, and to query a SQLServer database to retrieve the value for the second querystring parameter? Please ignore the security concern here. Thanks!
its called SPSecurityTrimmedControl
example:
<%# Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<SharePoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server"
AuthenticationRestrictions="AuthenticatedUsersOnly" Permissions="ManageWeb" PermissionContext="CurrentSite">
<INCLUDE OUR CONTROL / CONTENT HERE>
</SharePoint:SPSecurityTrimmedControl>
I ended up creating custom web parts developed using Visual Studio 2013 for each particular link that needed query string parameters to be built based on values retrieved from database.

How to add Promoted links web part to page and set JSLink

I am trying to deploy a Promoted links web par to the default.aspx page, following the article from Muawiyah Shannak http://code.msdn.microsoft.com/office/Sharepoint-2013-How-to-add-e2966a24#content
But I cant find out how to set the JSLink url in the markup.
<div>
<WebPartPages:WebPartZone ID="WebPartZone" runat="server" FrameType="None">
<WebPartPages:XsltListViewWebPart
ID="XsltListViewArticlePromotedList"
runat="server"
ListUrl="Lists/MyPromotedLinks"
IsIncluded="True"
NoDefaultStyle="TRUE"
Title="Images used in switcher"
PageType="PAGE_NORMALVIEW"
Default="False"
ViewContentTypeId="0x">
</WebPartPages:XsltListViewWebPart>
</WebPartPages:WebPartZone>
</div>
XsltListWebPart.JSLink property sets CSR file to rendering the List View:
<JSLink>~site/SiteAssets/PromotedLinks.js</JSLink>
where ~site is a URL token.
Please refer URLs and tokens in SharePoint 2013 for a more details.

Apply Web Part Connections to web parts on the ascx page of other web parts

I have created a visual web part that combines two other previously created web parts into one nicely styled web part. This is done simply by adding Register tags to the ascx page of the web part, and then adding the web part tags just as I would on a page layout, like so:
WebPart_ParentAssignmentsUserControl.ascx:
<%# Register tagprefix="WebParts" namespace="Microsoft.SharePointLearningKit.WebParts" assembly="Microsoft.SharePointLearningKit, Version=1.3.1.0, Culture=neutral, PublicKeyToken=24e5ae139825747e" %>
<%# Register tagprefix="MyChildrenWebPart" namespace="MLG2010.WebParts.MyChildren.MyChildrenWebPart" assembly="MLG2010.WebParts.MyChildren, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" %>
<WebParts:AssignmentListWebPart runat="server" ListScope="false" AllowEdit="True" AllowConnect="True" Title="Assignment List Web Part" IsIncluded="True" Dir="Default" SummaryWidth="150px" IsVisible="True" AllowMinimize="True" AllowHide="True" ExportControlledProperties="True" ZoneID="" ID="g_1c528b46_baf2_4cf2_a004_91f84c4f4556" FrameState="Normal" DisplaySummary="True" ExportMode="All" SuppressWebPartChrome="False" DetailLink="" HelpLink="" MissingAssembly="Cannot import this Web Part." PartImageSmall="" AllowRemove="True" ToolTip="Assignment List - Use this web part to keep track of your SharePoint Learning Kit assignments." HelpMode="Modeless" FrameType="Default" AllowZoneChange="True" PartOrder="0" Description="Display the assignments for an instructor or learner." PartImageLarge="" IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{1c528b46-baf2-4cf2-a004-91f84c4f4556}" WebPart="true" Height="" Width=""></WebParts:AssignmentListWebPart>
<MyChildrenWebPart:MyChildrenWebPart runat="server" PageSize="5" StudentsSiteURL="/student" PictureLibraryTitle="Students Picture Library" ADChildAttribute="otheripphone" Description="My WebPart" DefaultPictureURL="../../Students Picture Library/DefaultChild.jpg" ShowErrors="True" PictureLibraryUrl="../../Students Picture Library" Title="MyChildrenWebPart" ADEntryPoint="LDAP://dc=redconnect-test" __MarkupType="vsattributemarkup" __WebPartId="{d13a3729-e2b8-4436-ac1b-b75c914a3596}" WebPart="true" __designer:IsClosed="false" id="g_d13a3729_e2b8_4436_ac1b_b75c914a3596"></MyChildrenWebPart:MyChildrenWebPart>
The problem here, is that I need these two web parts to communicate via web part connections. since they are only added here on the aspx, sharepoint does not "know" about them, and thus they do not get a chrome and thus I cannot set up the web part connections in the browser.
Is there a way to set up web part connections on web parts that are added this way? Or maybe if I can just activate the chrome on these web parts?
You can define the connection statically. Note that using this way, you cannot create/modify/delete the connection using the browser.
See:
How to: Declare a Static Connection between Two Web Parts Controls
In the end, I separated the web part into the pieces that could connect normally, and then used styling to make it look as if they were one. I have not found any documentation on the consequences of putting web parts inside other web parts as i attempted.

MOSS 2007 team site page title

I'm trying to display the page title (html title) on the default.aspx page of a custom site template. The template is based on a MOSS team site template.
But the html page title is rendered empty. Can I change the code in the default.aspx and/or the sites master page to define the title myself? Details of the deafult.aspx and default.master page as below: Thanks.
Default.aspx:
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,multipages_homelink_text%>" EncodeMethod="HtmlEncode"/>
- <SharePoint:ProjectProperty Property="Title" runat="server"/>
</asp:Content>
default.master
<Title ID=onetidTitle><asp:ContentPlaceHolder id=PlaceHolderPageTitle runat="server"/></Title>
I'm not sure a understand your problem, but have you tried to enter your title like this in your .aspx file:
<asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
This is my title</asp:Content>
Or am I missing something obvious here?
Do you want to do it in code?
You maybe also have stumbled upon this bug. (although it's Ajax specific)
2 additional things:
Have you checked-in, published and approved the master page?
Have you checked in the .aspx page?
If you have Sharepoint Designer, then its matter of fiew clicks to modify page title.
I checked the Master page the site was inheriting which was the site template master page. I change the title tag to display the site title using the Sharepoint ProjectProperty tag and property title.
<Title ID=onetidTitle> <asp:ContentPlaceHolder id=TSM_PlaceHolderPageTitle runat="server">Parent Site Title- <SharePoint:ProjectProperty Property="Title" runat="server"/></asp:ContentPlaceHolder></Title>

How to create a SharePoint feature that adds Web Part Pages to a Document Library?

I need to create a SharePoint feature that will create some content pages. I know how to create a ListInstance element for a Document Library, but how can I add web part pages to the list?
I have created some pages with the Web UI (_layouts/spcf.aspx), but how can I use them in my ListInstance? Is there a way to export this content and use it in my feature? Or is there a different way I should approach this?
A while ago I did something similar but then with Publishing Pages. Using a Feature I was provisioning Publishing Pages to the Pages library. Although it's not exactly the case you've described it might give you some idea of how to approach it. I have described my findings on my blog # http://blog.mastykarz.nl/provisioning-publishing-pages-features-declarative-markup/
I am afraid that you will not be able to do so using the ListInstance Feature, ListInstance will only allow you create a List based on the Existing List Template. But you can try create a new Schema for the list and You need to do that in the schema.xml of the List. At the end of the schema.xml file you will see a entry as below
<Forms>
<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
</Forms>
This dictates the list of forms the List has. You need to add another form you can make another entry say for example
<Form Type="NewForm" Url="NewForm2.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />
You will get another page NewForm2.aspx, UI will be as per the File form.aspx that is present in the location C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\TEMPLATE\Pages, You can copy form.aspx and make changes to that and point the SetupPath url to the new file. In case if you want to create a new View page you can do so using the tag of the Schema.xml

Resources