I was looking as to how can i Declaratively set the Audience Targeting property for my Publishing Pages while creating them, well i knew we could do it using Object Model and feature receiver, but i was looking something we could set as configuration, for e.g "ContentType", "PublishingPageLayout" which could be specified as configuration and sharepoint infrastructure handles it for us.
I started w/ my best friend "SharePoint Manager" which gives you a way to dig in details for any kind of info which you could retrive it using Object Model. So looking at different properties i encoundtered that Audience Targeting property value as "ows_Audience=";;;;Managers" ( i think i dont need to talk about what's "ows" ) I picked the property "Audience" and its value which is ";;;;Managers" (this is how Audience Property is stored).
Lets quickly write simple and quick xml configurations and let sharepoint do the work for us.
So a simple feature which creates a Publishing page based on Welcome Pagelayout
Feature.xml
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="{64586CC8-3828-4222-9C16-E0B3450CD3D0}"
Title="Zevenseas Support - Create a new Page."
Description="Create page using Audience Property Setting."
Version="12.0.0.0"
Scope="Web"
Hidden="FALSE"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="LayoutFiles.xml" />
</ElementManifests>
</Feature>
LayoutFiles.xml
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="RollupPage" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
<File Url="default.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Akhilesh Default HomePage" />
<Property Name="Audience" Value=";;;;Managers" />
</File>
</Module>
</Elements>
Note:
1) You have to make sure, you have the default.aspx page layout or whichever pagelayout you are using, else you won't be able to create page instance.
2) "Managers" group is already created in site you are deploying else it would break (i've not tested this but i'm assuming)
Happy SharePointing!!!!!!!