Hi,
How do I get the data of a page (item)?
I now we can get the TopPageID, but I need the data of that page. Is there a way to reference a page by ID and get all of the data?
Nuno
Hi,
How do I get the data of a page (item)?
I now we can get the TopPageID, but I need the data of that page. Is there a way to reference a page by ID and get all of the data?
Nuno
Hi Nuno
Something like this:
var page = Dynamicweb.Frontend.Page.FindPage(123); page.Value("PageMenuText"); page.ID; page.AreaID;
You can get a Dynamicweb.Frontend.Page (same type as Pageview.Page in Razor) or a Dynamicweb.Content.Page using the Dynamicweb API in Razor:
@Dynamicweb.Frontend.Page.FindPage(pageId) @Dynamicweb.Content.Page.GetPageById(pageId)
Best regards,
Mikkel
Hi Nicolai and Mikkel,
Great answers both of you. This info should be in the Razor manual ;) Seems like basic info for frontend developers without VisualStudio and/or .NET knowledge
Nuno
Hi Guys,
I still can't get this to work. Am I the bug, or is there another :P Check out in attach the template.
I cannot get @Dynamicweb.Content.Page.GetPageById(pageId) to work, only FindPage method
I cannot get the TopPageID either, using a hardcoded value for the time being
How will I get the item values (filelds) for this page?
Nuno
Try using it like this:
@{ var topPageId = (int)Pageview.Area.get_Value("AreaFirstActivePage"); var topPage = Dynamicweb.Frontend.Page.FindPage(topPageId); } @topPage.AreaID @topPage.ID @topPage.get_Value("PageMenuText")
Best regards,
Mikkel
Hi Mikkel,
That worked but not when I need to make a few adjustments. I tried looking into the documentation with no luck :(
What I need is a ParentPage's Item value. This is what I tried, but DW does not tell me where the error is:
@{
var parentPageId = (int)Pageview.Page.get_Value("PageParentID");
var parentPage = Dynamicweb.Frontend.Page.FindPage(parentPageId);
}
@parentPage.AreaID
@parentPage.ID
@parentPage.get_Value("Item_System_Name")
Also, how could we know all of the possibilities under "get_Value"?
Can you help?
Nuno
Does Dynamicweb report an error or does your code simply not work as intended?
You can get a list of keys for use in get_Value like this:
<pre> @foreach (System.Collections.DictionaryEntry e in topPage.Values) { @: @e.Key: @e.Value } </pre>
Hi Mikkel,
Perfect! We got it now. GREAT!
Nuno
You must be logged in to post in the forum