Microsoft Content Management Server - Next and Previous Navigation

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > October 2004 > Next and Previous Navigation





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 Next and Previous Navigation
Charles Bell

2004-10-28, 7:48 am

Hi All,

I'm trying to create a simple Channel navigation that will allow me to have
two links at the bottom of the page - next and previous posting.

Now, I've found it pretty easy to get a handle on the posting, and I know
how to get a hold of any of the postings within the channel using
context.Channel.Postings[...]

however, I'm trying to do this within the context of a Current posting. But
it doesn't seem to be very straightforward to actually find out the current
posting's ordinal within the channel.

What I'd really like to do is something along the lines of:

Posting nextPosting = context.Channel.Postings[<current posting
position> + 1]
Posting previousPosting = context.Channel.Posting[<current posting
positon> - 1]

(Obviously, I'd do checks for array out of bounds, etc).

Can anyone shed any light on an easy way of getting the next and previous
posting based on the ordinal sorting of the channel and the position of the
current posting, WITHOUT (hopefully) having to iterate through the posting
collection.

Thanks


Stefan [MSFT]

2004-10-28, 7:48 am

Hi Charles,

you mean the number?
you need to enumerate the collection from the beginning until you get the
posting with the identical GUID.
Then you have the ordinal.

Here is some pseudo code:

Channel curCh = CmsHttpContext.Current.Channel;
Posting curP = CmsHttpContext.Current.Posting;
int ordinal = -1;
for (int index = 0; index < curCh.Postings.Count; index++)
{
if (curCh.Postings[index].Guid == curP.Posting.Guid)
ordinal = index;
break;
}

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Charles Bell" <charlie@bang.co.uk> wrote in message
news:#MDICfNvEHA.1292@TK2MSFTNGP10.phx.gbl...
> Hi All,
>
> I'm trying to create a simple Channel navigation that will allow me to

have
> two links at the bottom of the page - next and previous posting.
>
> Now, I've found it pretty easy to get a handle on the posting, and I know
> how to get a hold of any of the postings within the channel using
> context.Channel.Postings[...]
>
> however, I'm trying to do this within the context of a Current posting.

But
> it doesn't seem to be very straightforward to actually find out the

current
> posting's ordinal within the channel.
>
> What I'd really like to do is something along the lines of:
>
> Posting nextPosting = context.Channel.Postings[<current posting
> position> + 1]
> Posting previousPosting = context.Channel.Posting[<current posting
> positon> - 1]
>
> (Obviously, I'd do checks for array out of bounds, etc).
>
> Can anyone shed any light on an easy way of getting the next and previous
> posting based on the ordinal sorting of the channel and the position of

the
> current posting, WITHOUT (hopefully) having to iterate through the posting
> collection.
>
> Thanks
>
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com