开发者

Using a Generic Event Handler to Access Conent Nodes in Umbraco

Folks,

I have written a .Net Generic Event Handler to respond to JavaScript requests using JSON responses. All of that will be great(I think), but I need to figure out how to access the Content Nodes within my Content tree. Specifically, these nodes are event dates, and they are located below the event calendar node, which is under the root.

Root->EventCalendar->Events.

The issue I am having is that my ashx开发者_StackOverflow社区 file lives in my usercontrols folder. Can anyone give me an idea as to how to "remotely" tap into the node structure? I have had no using a user control on a template, which is then used in a page. At that point, I have had no problem navigating the node structure, but in this case, where the control is not embedded in a page, I am at a loss.

I definitely appreciate any help, and I am sure you know by my question, I am a newbie to Umbraco!

Thanks, Jason


You can access your content using the umbraco.NodeFactory.Node object. This provides access to all the published content and is the most efficient way of retrieving content.

So you could do something like:

INode calendarNode = umbraco.NodeFactory.Node.GetNodeByXpath("root/EventCalendar");

List<INode> events = calendarNode.ChildrenAsList;

foreach(var eventNode in events)
{
    DateTime createdDate = DateTime.Parse(eventNode.GetProperty("createDate").Value);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜