views:

275

answers:

1

Is there a solution to the following that I am missing in SharePoint/CAML. Note that I'll give a specific example of using a URL on a Redirect Page (publishing feature content type), but the issue is broader in scope than provisioning a Redirect Page. It is really a question anywhere a "URL" field/property can be set (web parts, pages, etc).

Like most SharePoint developers, I have a set of environments: "DEV", "QA", "STAGING", and "PROD". I have a few "locale" specific sites in each environment:

www.mysite.com us.mysite.com uk.mysite.com etc...

Sites in each environment, other than PROD, have an environment prefix associated with them, for example:

us.dev.mysite.com us.qa.mysite.com us.staging.mysite.com

Probably a pretty common setup...

I have a need to redirect users to a page that only exists on the "www" site from each of the locale specific sites. I need the redirect to redirect users to appropriate "www" site for the environment they are currently in. For example, if I am in dev in the uk locale, and I visit the redirect page, I should be redirected to the www dev site.

I was hoping to use a "Redirect Page" from SharePoint to accomplish this. I was going to setup a feature (with module elements) to provision an instance of the "Redirect Page" content type. This allows me to specify a url to redirect users to. If I am provisioning the page through CAML, however, I need a way to ensure the redirect is appropriate for the environment being specified. I cannot trust myself, or other devs, to remember to change the URL each time we build and deploy the wsp to each environment.

Is there anyway in SharePoint/CAML to do some sort of token replacement based on some switch when specifying field/property values?

A: 

I'm not sure I understand you requirements entirely, but for the variance of environments (Dev, QA, Staging, Prod), I would use Chris O'Brien's 'Config Store' feature: http://www.sharepointnutsandbolts.com/2008/05/introducing-sharepoint-config-store-for.html This will create a simple list where you can store infomation specific to the current environement.

This combined with Gary Lapointe's stsadm extentions: http://stsadm.blogspot.com/2007/08/stsadm-commands_09.html

You can use this to push out the correct values per environment to your 'Config Store' and in your code, query the 'config store list' for the environment value.

For sites that represent different countries, you can vary them on the regional settings property for that site/site collection/web. This adds another dimension to check in your code.

In your case, you may have entry in the config store called 'MyPrefixUrl' and call its value + relative path to redirect the user to the correct place.

Hope this doesn't confuse you.

Zeb