Getting A Collection of "Pages"

May 16, 2009 at 12:13 AM

So through the Oxite installation, I added a few "Pages". For example's sake, let's say I have Pages that match what is on Codeplex ... "Home", "Downloads", "Discussions", "Issue Tracker", etc

I'm creating a new Skin and in doing so I want to be able to dynamically create a toolbar.

The way the Default skin is set up, it appears that Header.ascx just hard codes "Home" and "About" and uses the Url.Pages("About") method.

Is there a collection that would allow me to loop through it in the Header.ascx control and do something like this?

<%foreach (Page p in Url.Pages) {%>

<div id='<%=p.SomeProperty%>'><%=p.SomeOtherProperty%></div>

<%}%>

Pretty new at this so any information on the underlying objects are obviously appreciated.

Coordinator
May 17, 2009 at 6:34 PM

We don't have a way to do that at the moment.

You would need to get the data down to the view to loop through all the pages.  It's a bit complicated at the moment to do that.  You would need to add and register a new ActionFilter that gets the list of pages and sticks them into the current model and then in the view, loop through those pages that are in the model.

I could setup some of this code in Oxite and check it in because I think being able to get a list of pages from a filter could be useful to others.  But you would need to register it yourself and then use it in the view.

Would you want all pages recursively or just the root level pages?

May 18, 2009 at 2:47 PM

Well for this purpose it would just be the root level.

I could see building nested menus out of a similar feature though, I'm not too picky on how you build it ... just curious whether there was a way to do it with existing objects.