This file could be stored in the the Umbrco config folder and easily edited. Basically, what I'm looking for is a data-driven custom section where I don't have to manually edit that assembly that creates the navigation tree.
Yes, I'd love to see your tree code. Are you intending to store your config file in the Umbraco config folder? I figured then you could edit it with the ConfigTree package...
Here's an example of how you'd do it in the Render() method of the new appTree:
public override void Render(ref XmlTree tree)
{
String configFile = HttpContext.Current.Server.MapPath("~/config/customPages.config");
if (File.Exists(configFile))
{
XmlDocument configDoc = new XmlDocument();
configDoc.Load(configFile);
if (configDoc != null)
{
XmlElement root = configDoc.DocumentElement;
foreach (XmlNode node in root.ChildNodes)
{
if (node.Name.ToUpper() == "PAGE")
{
if ((this.m_id == -1) && !this.IsDialog)
{
String label = node.Attributes["label"].Value;
String url = node.Attributes["url"].Value;
// create a new tree/node
NullTree pageTree = new NullTree(this.m_app);
pageTree.RootNode.Action = String.Concat("javascript:go('", url, "');");
pageTree.RootNode.Text = label;
// add the node to the tree
tree.Add(pageTree.RootNode);
}
}
}
}
}
}
What is happening here is that the XML config file is opened, loop through each of the ChildNodes, then creating new appTrees from them.
This isn't what I'm using for my WP package, but it's similar. I haven't tested this code either, just whacked it together as an example of what you could do. I've used NullTree - just because I didn't know what else to use for this example.
XML/Config Driven Custom Section
Has anyone create a custom section with a XML-driven tree? Like:
This file could be stored in the the Umbrco config folder and easily edited. Basically, what I'm looking for is a data-driven custom section where I don't have to manually edit that assembly that creates the navigation tree.
Hi Robert,
Yes, it's possible. I am using this approach for my upcoming WordPress integration package.
My base appTree reads the XML config, loops through each node/page and creates child appTrees from that.
Let me know if you want to see a code sample, (as my WordPress integration package is not where near release yet).
Cheers, Lee.
Yes, I'd love to see your tree code. Are you intending to store your config file in the Umbraco config folder? I figured then you could edit it with the ConfigTree package...
Hi Robert,
Here's an example of how you'd do it in the Render() method of the new appTree:
What is happening here is that the XML config file is opened, loop through each of the ChildNodes, then creating new appTrees from them.
This isn't what I'm using for my WP package, but it's similar. I haven't tested this code either, just whacked it together as an example of what you could do. I've used NullTree - just because I didn't know what else to use for this example.
Good luck, Lee.
Cool, actually got it working! Thanks for the ideas... I borrowed some code from another project I found that seemed to handle the tree build better.
>> code from another project I found that seemed to handle the tree build better
Sounds interesting... care to share?
I'll post the code here in a bit.
Tree code:
XML file:
is working on a reply...