Page creation steps using API
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. ?
Any help regarding my query above?
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!
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.
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);
Hello Chetan,
Have you tried to suppress security checks?
pageManager.Provider.SuppressSecurityChecks =
true
;
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
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.