Developer forum

Forum » Development » Loop through all Root pages of Area?

Loop through all Root pages of Area?

Dmitrij Jazel
Reply

Hej guys,

Can I somehow loop through all the root pages in the area, or atleast get their IDs in Razor?

I foud: Pageview.Area.Values["pagearray"] 

here: https://github.com/dynamicweb/razor/wiki/Pageview.Area.Values

But am not sure if I could pull the pages I need. Or whether that is correct way

/Dmitrij


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Like this:

foreach (int pageid in (System.Collections.ArrayList)Pageview.Area.get_Value("AreaMainPages"))

{

}
Votes for this answer: 1
 
Dmitrij Jazel
Reply

After some tryal and error, got so far :)

System.Collections.ArrayList pIDlist = (System.Collections.ArrayList)Pageview.Area.get_Value("pagearray");
        foreach (int pageID in pIDlist)
        {
            var page = Dynamicweb.Frontend.Page.FindPage(pageID);
            <p>@pageID</p>
            <table>
                <tr><th>Key</th><th>Value</th></tr>
                @foreach (System.Collections.DictionaryEntry e in page.Values)
                {                    
                    <tr><td>@e.Key</td><td>@e.Value</td></tr>
                }
            </table>           
        }

Than just need to check for "pagelevel" value casted as (int) The root ones are with value 1

 

You must be logged in to post in the forum