umbraco 4.0

Reference
A collection of code samples to perform common tasks with the umbraco API such as creating and publish documents, members and users.

Chapters

Creating a document

Sample code to create a document and publishes it

remember to add the cms.dll, businesslogic.dll and umbraco.dll to your project.

Add references to the right namespaces at the top of your .cs file

using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;

Perform the creation

//Get the type you would like to use by its alias
//and the user who should be the creator of the document
DocumentType dt = DocumentType.GetByAlias("Textpage");
User author = User.GetUser(0);

//create a document with a name, a type, an umbraco user, and the ID of the document's parent page.
//To create a document at the root of umbraco, use the id -1
Document doc = Document.MakeNew("My new document", dt, author, 1018); 

//after creating the document, prepare it for publishing
doc.Publish(author);

//Tell umbraco to publish the document
umbraco.library.PublishSingleNode(doc.Id);

RSS Feed for Documentation RSS Feed for docs (syndicate)

  • Latest forum posts

Brilliant umbraco hosting provided by FAB-IT