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
<?xml version="1.0" encoding="utf-8"?>
Title="Zevenseas Support - Create a new Page."
Description="Create page using Audience Property Setting."
<ElementManifest Location="LayoutFiles.xml" />
<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" />
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)