|
Home > Archive > Microsoft Content Management Server > December 2005 > Return channels if posting exists
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 |
Return channels if posting exists
|
|
| collie 2005-12-19, 7:48 am |
| Hi,
I populated a dropdownlist populated with all the channels that I have in my
site.
however, i want to only show those channels that have a posting named
Contacts under a subchannel called Contacts and I am not sure how to do that.
My site hierarchy is as follows:
Channels (root channel)
|_Site (channel)
|_School (channel under Site)
|_Psychology (channel under School)
|_Contacts (should contain a posting called Contacts)
My current code to populate a dropdownlist (currently returns all the
channels)
Private Sub FillContacts()
Empty the ListBox of all previous entries
ddl_Contacts.Items.Clear()
Dim startChannel As Channel =
CType(CmsHttpContext.Current.Searches.GetByPath("/Channels/Site/Subsites"),
Channel)
' ' Get a collection of channels in the current channel
Dim subChannels As ChannelCollection = startChannel.Channels
' ' Make sure that we got a collection
If Not (subChannels Is Nothing) Then
Dim subChannel As Channel
For Each subChannel In subChannels
ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
Next subChannel
End If
End Sub
Thanks
| |
| Chester Ragel 2005-12-19, 5:55 pm |
| Hi Collie,
I'm not sure whether I got your question correctly. Do you want to show
channel Psychology, if you have a posting in Channel - Contacts with the
name Contacts? If that is the case you can add a validation before adding it
to the dropdown list.
Replace your
For Each subChannel In subChannels
ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
Next subChannel
with
For Each subChannel In subChannels
If (Not subChannel Is Nothing) And (subChannel.Channels.Count > 0) Then
Dim validationChannels As ChannelCollection = subChannel.Channels
If (Not validationChannels Is Nothing) And (validationChannels.Count >
0) Then
Dim validationChannel As Channel
For Each validationChannel In validationChannels
If (Not validationChannel Is Nothing) And (validationChannel.Name =
"Contacts") And (Not validationChannel.Postings.Item("Contacts") Is Nothing)
Then
ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
End If
Next validationChannel
End If
End If
Next subChannel
Cheers,
Chester.
~Are you using MCMS? Then try MCMS Manager -
http://mcmsmanager.sourceforge.net~
"collie" <collie@discussions.microsoft.com> wrote in message
news:11BBC504-68C6-40A0-8446-736EC5B075D5@microsoft.com...
> Hi,
>
> I populated a dropdownlist populated with all the channels that I have in
my
> site.
> however, i want to only show those channels that have a posting named
> Contacts under a subchannel called Contacts and I am not sure how to do
that.
> My site hierarchy is as follows:
> Channels (root channel)
> |_Site (channel)
> |_School (channel under Site)
> |_Psychology (channel under School)
> |_Contacts (should contain a posting called Contacts)
>
> My current code to populate a dropdownlist (currently returns all the
> channels)
> Private Sub FillContacts()
> Empty the ListBox of all previous entries
> ddl_Contacts.Items.Clear()
> Dim startChannel As Channel =
>
CType(CmsHttpContext.Current.Searches.GetByPath("/Channels/Site/Subsites"),
> Channel)
>
> ' ' Get a collection of channels in the current channel
> Dim subChannels As ChannelCollection = startChannel.Channels
> ' ' Make sure that we got a collection
> If Not (subChannels Is Nothing) Then
> Dim subChannel As Channel
> For Each subChannel In subChannels
> ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
> Next subChannel
> End If
> End Sub
>
> Thanks
>
| |
| collie 2005-12-21, 7:55 am |
| Thanks Chester :-)
"Chester Ragel" wrote:
> Hi Collie,
>
> I'm not sure whether I got your question correctly. Do you want to show
> channel Psychology, if you have a posting in Channel - Contacts with the
> name Contacts? If that is the case you can add a validation before adding it
> to the dropdown list.
>
> Replace your
>
> For Each subChannel In subChannels
> ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
> Next subChannel
>
> with
>
> For Each subChannel In subChannels
> If (Not subChannel Is Nothing) And (subChannel.Channels.Count > 0) Then
> Dim validationChannels As ChannelCollection = subChannel.Channels
> If (Not validationChannels Is Nothing) And (validationChannels.Count >
> 0) Then
> Dim validationChannel As Channel
> For Each validationChannel In validationChannels
> If (Not validationChannel Is Nothing) And (validationChannel.Name =
> "Contacts") And (Not validationChannel.Postings.Item("Contacts") Is Nothing)
> Then
> ddl_Contacts.Items.Add(subChannel.DisplayName.ToString())
> End If
> Next validationChannel
> End If
> End If
> Next subChannel
>
> Cheers,
> Chester.
>
> ~Are you using MCMS? Then try MCMS Manager -
> http://mcmsmanager.sourceforge.net~
>
> "collie" <collie@discussions.microsoft.com> wrote in message
> news:11BBC504-68C6-40A0-8446-736EC5B075D5@microsoft.com...
> my
> that.
> CType(CmsHttpContext.Current.Searches.GetByPath("/Channels/Site/Subsites"),
>
>
>
|
|
|
|
|