For umbraco versions: umbraco3.0

MIsc
In this book I'll occasionally add a new chapter explaining a new feature/enhancement inside v3 of umbraco.

Chapters

New feature: NodeFactory as DataTable object

In those rare occasions where you'd prefer a .NET User Control over a simple XSLT (like a list with editing options), the nodeFactory have come handy for many of us in v2.1.

The nodefactory (in the umbraco.presentation.nodeFactory namespace) is a wrapper for the in-memory XML for much easier access to published data from .NET. To display children from the current node you could use this syntax:

Node currentPage = Node.GetCurrent();
foreach (Node child in currentPage.children)
   [...]

While this was handy, we do wanna make sure that we separate logic and presentation and therefore use some of the declarative controls like a repeater for the markup. Even though that was still possible with the nodeFactory in v2.1 quite a lot of manual work was needed.

With v3 say hello to a little method ChildrenAsTable(). This little method will return a .NET DataTable that includes both your own properties (using your property Name as Column headers) as well as the default node properties such as page name and create date, making access to your data easy with the default <%#Eval("NodeName")%> syntax.

There's even an overload that takes the alias of a Document Type as a filter, ensuring that only nodes of that Document Type will be added to the table.

With this new little method, we can easily bind to default declarative controls with just two linies of code:

MyRepeater.DataSource = Node.GetCurrent().ChildrenAsTable("newsItem");
MyRepeater.DataBind();

Enjoy :-)


Brilliant umbraco hosting provided by FAB-IT