Developer forum

Forum » Development » Get page Item type properties from API

Get page Item type properties from API

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I have a situation where I get a list of PageId's (from an ItemRelationList) and apart from the regular properties of the page, I need to also find valus of the custom properties that are set through the PageProperties ItemType.

So far, I have read the page object by using the API:

var relatedPage = Dynamicweb.Content.Page.GetPageById(pageID);

And I can read the regular properties:

@relatedPage.MenuText

Assuming my custom property is called Page_Icon, how should I read the value of it?

I am using 8.9.1.13

Thanks,

Adrian

 


Replies

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Adrian,

 

You should be able to do something like this:

var pageIcon = relatedPage.PropertyItem == null ? null : relatedPage.PropertyItem["Page_Icon"];

I haven't tested the code, but hopefully you can use the idea of it :-)

 

Best regards, Anders

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Thank you very much Anders.

That's what I needed. A head-start.

Thank you,

Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Anders,

At first glance, it looks like the PropertyItem is available only for PageView.

I have to dig deeper.

Thanks,

Adrian

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Adrian,

 

It should be available in the Page class: https://www.screencast.com/t/7QbwKcu4uWS

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Anders,

I have used Dynamicweb.Content instead of Dynamicweb.Frontend.

That's because Dynamicweb.Content seems to have the GetPageByID method that returns the Page object

And I am not sure if Dynamicweb.Frontend is available in DW8. At least I could not find it in the API or I did not know where to look for it.

Adrian

 
Nicolai Pedersen
Reply

Frontend.Page is ONLY available in DW8 - and it has a method called findpage(id) that you should use. It is faster than working on content.

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

My test is from DW8

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

Thank you very much.

I feel so stupid. The method was already in Anders's printscreen.

I have managed to make it work.

Thank you very much for your patience.

Adrian

 

You must be logged in to post in the forum