Microsoft Content Management Server - Vb.NET Code question: Accessing a hidden (Hide When Published) cha

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > November 2007 > Vb.NET Code question: Accessing a hidden (Hide When Published) cha





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 Vb.NET Code question: Accessing a hidden (Hide When Published) cha
Confused Richi

2007-11-05, 1:24 pm

Hi, I am new to MCMS and am having a bit of trouble coding the ASP.NET for
one of my templates. I need to list out the postings for a hidden channel
("Hide When Published") and am hitting problems when I load the code in the
"Live" state as it says the channel "managevacancies" channel is not set to
an instance of an object. Does anyone know a way to access the hidden channel
in the live/published state?

'Get the Manage Vacancies (managevacancies) channel
Dim currentChannel As Channel = cmsContext.Channel

Dim parentChannel As Channel = currentChannel.Parent
Dim parentName As String = parentChannel.DisplayName
Dim currentCollection As ChannelAndPostingCollection =
currentChannel.AllChildren
Dim manage_vac_chan As Channel =
currentCollection.Item("managevacancies")

Dim vac_collection As PostingCollection = manage_vac_chan.Postings '
<< Object reference not set to an instance of an object here...

Thanks in advanced.
Rich
Stefan Goßner [MSFT]

2007-11-05, 1:24 pm

Hi Rich,

to access hidden channels you need to use the following code:

CmsHttpContext.Current.SessionSettings.AutoFilterHidden = false;

.... now access the channel.

Don't forget to change it back afterwards as this is a per-session setting.

CmsHttpContext.Current.SessionSettings.AutoFilterHidden = true;

Cheers,
Stefan


"Confused Richi" <Confused Richi@discussions.microsoft.com> wrote in message
news:54798778-2331-45DD-8F7D-3477378BD575@microsoft.com...
> Hi, I am new to MCMS and am having a bit of trouble coding the ASP.NET for
> one of my templates. I need to list out the postings for a hidden channel
> ("Hide When Published") and am hitting problems when I load the code in
> the
> "Live" state as it says the channel "managevacancies" channel is not set
> to
> an instance of an object. Does anyone know a way to access the hidden
> channel
> in the live/published state?
>
> 'Get the Manage Vacancies (managevacancies) channel
> Dim currentChannel As Channel = cmsContext.Channel
>
> Dim parentChannel As Channel = currentChannel.Parent
> Dim parentName As String = parentChannel.DisplayName
> Dim currentCollection As ChannelAndPostingCollection =
> currentChannel.AllChildren
> Dim manage_vac_chan As Channel =
> currentCollection.Item("managevacancies")
>
> Dim vac_collection As PostingCollection = manage_vac_chan.Postings
> '
> << Object reference not set to an instance of an object here...
>
> Thanks in advanced.
> Rich



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com