|
|
 Rank: Devotee
Joined: 4/13/2007 Posts: 57 Location: Arlington, VA
|
I'm building a system that the client needs to be able to open or close on their own. I'd like to be able to offer a page property called "isOpen" on the main page of the system. The problem I am having is that I am unable to access that property on subsequent pages in the system when calling the specific control each sub page requires. I've tried prefacing the umbraco property Aliases with both $ and # - neither seem to handle recursion.
Help!
|
|
 Rank: Devotee
Joined: 4/13/2007 Posts: 57 Location: Arlington, VA
|
Nevermind - finally found the thread where this was discussed. However, now that I know I can't do this the simple way, let me ask about the hard way. Is there a way to programmatically search for a property up the tree in C#?
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 821 Location: Århus, Denmark
|
I'm not shure that there is any easy way to do this, other than check if the property is set on the current node, and then iterate up through the tree until a node contains a value for the property.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 821 Location: Århus, Denmark
|
Would be nice with a getProperty(string alias, bool recursive) method though...
|
|
 Rank: Devotee
Joined: 4/13/2007 Posts: 57 Location: Arlington, VA
|
Hmmm. I'm willing to give it a try, but can someone tell me how to access the current node from my own custom usercontrol?
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 821 Location: Århus, Denmark
|
In C# Code: umbraco.presentation.nodeFactory.Node n = new umbraco.presentation.nodeFactory.Node.GetCurrent();
|
|
 Rank: Devotee
Joined: 4/13/2007 Posts: 57 Location: Arlington, VA
|
Wow - fast! Thanks!
|
|
 Rank: Devotee
Joined: 4/13/2007 Posts: 57 Location: Arlington, VA
|
Just remembered this: here's the method in C#: Code: protected string GetRecursiveProperty(Node selectedNode, string propertyAlias) { Property p = selectedNode.GetProperty(propertyAlias); if (p != null) return p.Value; else { if (selectedNode.Parent != null) return GetRecursiveProperty(selectedNode.Parent, propertyAlias); else return null; } }
remember to include this line: Code: using umbraco.presentation.nodeFactory;
|
|
|
Guest |