Microsoft Content Management Server - Renaming a channel

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > August 2006 > Renaming a channel





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Renaming a channel
mikevanhoff

2006-08-18, 1:25 pm

we have several CMS Sites, and want to duplicate one of them. What is the
best method of renaming a channel and changing the code pages to make then
reflect the new channel? I am looking for some scripting sources etc.

Thanks in Advance
Becky VanBruggen

2006-08-21, 1:24 pm

Mike,
Just as good coding practice in general, it's usually a good idea to store
hard coded paths to any resource, whether it's a regular .aspx page, an
image, a channel path, or whatever, in some central location, where it can be
easily modified, such as in the web.config. For CMS in particular, if I have
several top level category channels, I store the paths to these channels in
my web.config. So for instance, if I have a Search channel, I'd put
"/Channels/Search/" in my web.config. Sometimes I'd also go so far as to put
the name of the posting in my web.config as well, if I think there's the
slightest chance the name could change. That way, if the name of a channel
ever changes, your code doesn't have to; you just update the web.config and
every piece of code that references it will be updated.

So for example, my web.config might look like this:
<applicationSettings>
<add key="SearchChannel" value="/Channels/Search/" />
<add key="SearchPosting" value="Search" />
<add key="SearchResultsPosting" value="SearchResults" />
</applicationSettings>

Anytime I want to reference my Search posting in my templates, I would use
code something like this:

Posting searchPosting =
(Posting)CmsHttpContext.Searches.GetByPath(ConfigurationManager.ApplicationSettings["SearchChannel"]
+ ConfigurationManager.ApplicationSettings["SearchPosting"]);

If you're only changing the display name of a channel and you're leaving the
Name property of the channel alone, and your Searches are all being done by
Path, changing the DisplayName should have no effect on your searches.

When you mention changing the code pages to reflect the new channel names,
in what way are you referencing the channels? What sort of code needs to
change?

In terms of changing channel names en masse, I'd suggest writing a nested
method:

private void UpdateChannelName(Channel parentChannel, string newName)
{
foreach (Channel c in parentChannel.Channels)
{
c.Name = c.Name + newName; //(or whatever you're trying to change
the name to)
UpdateChanenlName(c);
}
}

Not sure if this is what you were looking for. Hope it helps some.

"mikevanhoff" wrote:

> we have several CMS Sites, and want to duplicate one of them. What is the
> best method of renaming a channel and changing the code pages to make then
> reflect the new channel? I am looking for some scripting sources etc.
>
> Thanks in Advance

mikevanhoff

2006-08-21, 1:24 pm

Hi Becky,

I am not sure that answers it completely, but it is sure a good start. I
will compare the sites' web config to your suggestion. I did not create
these sites, but I am now the one responsible for them. We have a current
site that works, but upper management wants the channel name to be different
than it was created with.
i.e. http://www.someplace.com/thisname should be
http://www.someplace.com/THATNAME
cosmetics I know, but they pay the bills.

Thanks

"Becky VanBruggen" wrote:
[vbcol=seagreen]
> Mike,
> Just as good coding practice in general, it's usually a good idea to store
> hard coded paths to any resource, whether it's a regular .aspx page, an
> image, a channel path, or whatever, in some central location, where it can be
> easily modified, such as in the web.config. For CMS in particular, if I have
> several top level category channels, I store the paths to these channels in
> my web.config. So for instance, if I have a Search channel, I'd put
> "/Channels/Search/" in my web.config. Sometimes I'd also go so far as to put
> the name of the posting in my web.config as well, if I think there's the
> slightest chance the name could change. That way, if the name of a channel
> ever changes, your code doesn't have to; you just update the web.config and
> every piece of code that references it will be updated.
>
> So for example, my web.config might look like this:
> <applicationSettings>
> <add key="SearchChannel" value="/Channels/Search/" />
> <add key="SearchPosting" value="Search" />
> <add key="SearchResultsPosting" value="SearchResults" />
> </applicationSettings>
>
> Anytime I want to reference my Search posting in my templates, I would use
> code something like this:
>
> Posting searchPosting =
> (Posting)CmsHttpContext.Searches.GetByPath(ConfigurationManager.ApplicationSettings["SearchChannel"]
> + ConfigurationManager.ApplicationSettings["SearchPosting"]);
>
> If you're only changing the display name of a channel and you're leaving the
> Name property of the channel alone, and your Searches are all being done by
> Path, changing the DisplayName should have no effect on your searches.
>
> When you mention changing the code pages to reflect the new channel names,
> in what way are you referencing the channels? What sort of code needs to
> change?
>
> In terms of changing channel names en masse, I'd suggest writing a nested
> method:
>
> private void UpdateChannelName(Channel parentChannel, string newName)
> {
> foreach (Channel c in parentChannel.Channels)
> {
> c.Name = c.Name + newName; //(or whatever you're trying to change
> the name to)
> UpdateChanenlName(c);
> }
> }
>
> Not sure if this is what you were looking for. Hope it helps some.
>
> "mikevanhoff" wrote:
>
Becky VanBruggen

2006-08-22, 7:29 pm

If you don't have any custom code at all in your templates, it might be that
you could make the change without any adverse effect to the site. CMS keeps
track of channels by their GUIDS, so changing the name of a channel only
causes a problem if you've harded some Searches.GetByPath() method somewhere.
If that's not the case, all you'd do is open up Site Manager, change the name
of the channel, and voila, you're done; everything should still work.

"mikevanhoff" wrote:
[vbcol=seagreen]
> Hi Becky,
>
> I am not sure that answers it completely, but it is sure a good start. I
> will compare the sites' web config to your suggestion. I did not create
> these sites, but I am now the one responsible for them. We have a current
> site that works, but upper management wants the channel name to be different
> than it was created with.
> i.e. http://www.someplace.com/thisname should be
> http://www.someplace.com/THATNAME
> cosmetics I know, but they pay the bills.
>
> Thanks
>
> "Becky VanBruggen" wrote:
>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com