#IContent or IPublishedContent?

1 messages · Page 1 of 1 (latest)

fickle timber
#

Hi

I have a controller/class where a method in this class is being called to get a page programmatically.

As an example, in Umbraco 13 I have 2 pages. When I'm on page 2, I'm calling this method to get some details from page 1.

I can get it by IContent (GetById) or some documents suggest using IPublishedContent.

Which is the correct way to get this type of record?

Thanks

hexed island
fickle timber
hexed island
#

Yes, you can always get it by Guid for IPublishedContent. Show some code where you're stuck and we'll have a look.

fickle timber
hexed island
#

that looks about right yeah, as long as it gives you an PublishedContent!

one tip, if you already have a content item, then content.Key will give you the Guid of that item. I don't know if that's the case for you but it might be useful.