Page creation steps using API

Posted by Community Admin on 04-Aug-2018 10:59

Page creation steps using API

All Replies

Posted by Community Admin on 21-Sep-2012 00:00

Hello, I have been looking into various documentations/articles around - 
1. How to create page dynamically 
2. How to set custom template to the page 
3. How to add controls (in house + custom) inside a specific place holder within assigned template
4. and finally how to save/publish this page
I can see various methods around each one of them (few of them are confusing for a new bee) and not sure which one should follow as a best practice. 
e.g. Few things confuse me as a starter
1. What's the diff using PageControl Or PageDraftControl while creating control ?
2. The control should be added to PageData or Edit handler of page ? 
3. Which is standard Page saving / publishing mechanism ?
4. Is PageManager.SaveChanges() necessary every time we add a new control, can't we not do it once after adding all the controls to page ?
5. For Publishing a page which one should we use 
Are there any good references around each of these to follow , any examples to start with etc. ? 

Posted by Community Admin on 24-Sep-2012 00:00

Any help regarding my query above?

Posted by Community Admin on 24-Sep-2012 00:00

the Sitefinity SDK has complete samples that demonstrate almost every one of these items. If you look at say the Non-Profit example, there is an additional project called sample Utilities that has a lot of helper methods showing how you can create an entire sitefinity website using the API.

these helper methods are called from the global.asax file in the sitefinity website project, so you can see how they are used and called.

I hope this is helpful!

Posted by Community Admin on 26-Sep-2012 00:00

Hello Chetan,

As Josh suggested you will find most of the answers of your questions in our SDK. I would also recommend going through our Documentation for further reference.

For starters you may want to check out Content Lifecycle  and Statuses articles. I would also suggest going through this article and its sub articles. There are code samples with explanations below them for both Native and Fluent APIs on page creation, setting a template to the page, adding controls etc. 

Regards,
Pavel Benov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Oct-2012 00:00

Hi All, I am facing another hurdle while publishing a page now - I am using below piece of code to publish the page

var bag = new Dictionary<string, string>();
bag.Add("ContentType", typeof(PageNode).FullName);
WorkflowManager.MessageWorkflow(pageId, typeof(PageNode), null, "Publish", false, bag);
At WorkflowManager.MessageWorkflow step it throws an error saying - "You are not allowed to modify this page".
Note : I have enca[psulated this page creation code inside a WCF service, which If i ran directly from browser it goes through without any error. But if the service call gets made from a client function it throws the error while publishing.
Am i misisng anything here? Also is teh publishing code piece right? Is there any better way Publishng a page .
Appreciate any help on this.

Thanks,
Chetan

Posted by Community Admin on 19-Oct-2012 00:00

Hello Chetan,

Have you tried to suppress security checks?

pageManager.Provider.SuppressSecurityChecks = true;

Don't forget to set it back to false once the page is published.   Kind regards,
Pavel Benov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 22-Oct-2012 00:00

Thanks Pavel for the suggestion.  Even after that service throws teh same error.
However what i observed is if i comment out my Publishing code (above 3 lines of code) then also service gets excuted without any error and we land on Edit page screen mode.
Will this (removing publishing piece of code) cause any issue or its ok to remove it and do only
pageManager.SaveChanges();

Thanks,
Chetan

Posted by Community Admin on 24-Oct-2012 00:00

Hi Chetan,

Can you submit a support ticket for this, so we can inspect this in more depth and get a better perspective on your scenario? 

Thank you in advance.

Greetings,
Pavel Benov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed