Get Section/Widget Identifier

Danny Winbourne asked on February 28, 2024 17:25

When a given page is saved with CI, I can see that the system assigns an Idenfier GUID to each section, zone, and widget

"sections":[{"identifier":"{GUID}","type":"Section.FiftyFifty","properties":{"Foo":"Bar"},"zones":[{"identifier":"{GUID}","name":"widgetZoneLeft","widgets":[{"identifier":"{GUID}","type":"SomeWidget"

Can I get these IDs in my ViewComponent class/code?

I can't see how/where this is exposed.

Recent Answers


Liam Goldfinch answered on February 29, 2024 09:38

I have done something like this before, when I needed to export the json (not saying this is a recommended approach as there might be a proper API you can use).

I did something like...

var currentPage = _pageDataContextRetriever.Retrieve<TreeNode>().Page;
var json = currentPage.GetStringValue("DocumentPageBuilderWidgets", string.Empty);

// Then deserialise this to a custom c# class that represents the editable area/sections/zones/widgets
var pagebuilderData = JsonConvert.DeserializeObject<CustomPageBuilderModel>(json);
0 votesVote for this answer Mark as a Correct answer

Danny Winbourne answered on February 29, 2024 10:18

Thanks, Liam. That's helpful, but I should have said that I need to identify the specific widget or section that I am currently on.

I'm surprised Kentico don't expose this Idenfier as a read-only field.

0 votesVote for this answer Mark as a Correct answer

Liam Goldfinch answered on February 29, 2024 10:23

If you think something like this would be useful and important to have (out of the box from Kentico), submit it as an idea on the roadmap.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.