Taf Munyurwa
Taf Munyurwa

Reputation: 1572

Deleting a webpart zone throught kentico api

So I have created a web part zone using the kentico API (kentico 11 webforms). I cannot find anything in the documentation about how to delete a CMSWebPartZone. Any ideas?

Upvotes: 0

Views: 99

Answers (1)

Michal Samuhel
Michal Samuhel

Reputation: 511

You can use PageTemplateInfo object:

PageTemplateInfo somepagetemplate = PageTemplateInfoProvider.GetPageTemplateInfo(DocumentContext.CurrentDocument.GetUsedPageTemplateId()); //where "SomeDocument" is a PageInfo object.

        //Get page template zones
        var zones = somepagetemplate.WebPartZones;

        //Grab instance of templat
        var instance = somepagetemplate.TemplateInstance;

        //Find particular zone
        var zone = zones.Find(a => a.ZoneID == "Test");

        //Remove zone from template instance
        instance.RemoveZone(zone);

        //Update template object
        somepagetemplate.Update();

Upvotes: 0

Related Questions