Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# tigermain 7/13/2007 3:19 PM

Im trying to develop a custom navigation module, but am struggling to work out how to get a Node from the Node Id in the code behind of a modules web form.

Therefore I am working with a class inheriting from BaseModuleControl

Any suggestions please
# Efie 7/13/2007 4:19 PM (edited 7/13/2007 4:26 PM)
Why would you use the node Id?

When you inherit from the BaseModuleControl (even when you don't inherit the BaseModuleControl) you can access the complete object graph for the menu by doing something like this in page_load (you don't even need the BaseModuleControl (checkout che available HierarchicalMenu.ascx):
private PageEngine _pageEngine

if (this.Page is PageEngine)
{
    this._pageEngine = (PageEngine)this.Page;	
    BuildMenu();
}


private void BuildMenu()
{
    Node rootnode = this._page.RootNode;
    //Do something with the rootnode, by accessing rootnode.ChildNodes;
    DoStuffToBuildMenu(rootnode.ChildNodes);
}

private void DoStuffToBuildMenu(IList nodes)
{
    //for each node call recursive
    //DoStuffToBuildMenu(node.ChildNodes);
}

When you still want to use the Node.Id, you can add the interface INodeService to the constructor of your modulecontrol and the IoC container will resolve the implementation for you.

You can ask the INodeService to get the Node by id:
_nodeService.GetNodeById(currentNodeId);

Take a look at the LanguageSwitcherModule, the INodeService is used there, there is also the Cuyahoga Module Development Guide with some information about IoC/Dependancy Injection and how to use it with Cuyahoga





# tigermain 7/13/2007 4:40 PM

Thanks the reason I want to use NodeId is because I am asking the user to specify the root node of the navigation from the admin console then iterating from there
# tigermain 7/16/2007 1:44 PM
OK that got me sorted for my first plan of action but I have decided to extend the ModuleSetting controls in order to full enable custom webcontrols in the admin console. This has lead me to inventing a ICustomModuleSetting interface which does no inherit from any previous class (unless you suggest otherwise). So the question is how can I get access to the object hierarchy through this object, which is in essence a static method being called from the SettingControlHelper class?? Can I pass some form of context or object from this point?
# Efie 7/17/2007 11:49 AM
I don't know what do you exactly mean by full enabling custom webcontrols in the admin console? I can't see what do you exactly want to achieve...

Just a suggestion:

When you inherit the adminpage from the AdminBasePage, you have already a few properties there, Section, Node, so there you have acces to the full object-hierarchy, maybe you can do something with those objects, passing them inyour ICustomModuleSettings for example?










# tigermain 7/17/2007 3:04 PM
Don't worry I have solved the problem by passing the site object through to my custom settings - which are essentially classes, which inherit an interface and expose 3 methods:

SaveSettingToString
GetWebControl
PopulateControlFromValue

This allows my modules to have completely customisable setting controls, i.e my nav module now has a dropper which selects all XSL files in the templates XSL folder and I have a listbox which allows individual page selections
# gedw99 7/20/2007 2:21 PM
Hey tigermann,

i started working on the same thing but got waylaid.

This is a great feature, because at the moment you have no run time control over it.

The other aspect si that then you can also have a few properties to control the levels it renders, so that you can have top nav, and then a side nav for level 2.
Or you can just write you won module, drop it on and configure it through admin just like any other section.

i hate to ask, but would you be happy to share this with the community? It just such an important feature and one of the little pains about the current implementation. No disrespect intended Martin.

Did you have to hack the base classes much to get it to play nice?



Ged
# tigermain 7/20/2007 2:32 PM
Yes I had to change a few of the libraries in the web project (and I added an interface to the core), but other than that its a pretty self contained module. That said these changes are no destructive and work happily with the standard 1.5 stuff.

Its all XML driven and I am using it to show 4 different menus on the site all with different root nodes etc.

If you're happy to hack up your core then I might be able to share it (would need to work out what I'd changed first, as our system is quite far from teh original 1.5 base code now)
# gedw99 7/25/2007 9:52 AM
I have hacked up my code base considerably also.
if you can just send the relevant base classes and mod i can see where the intersection points are i imagine.

gedw99 AT hotmail DOT com

You said tis XML driven - why? Surely the page nodes structure inherent in the SiteStructure is what you want to use to drive it?
And of course the Module settings to help tel it what levels it shoudl use?

Anyway, if you can send the basic module i can work it out.
# tigermain 7/26/2007 10:56 AM
I'll have a think about how I can send it over, as I spent friday afternoon hacking the admin section out of the web project and into its own, I have now also added a Core.Web as well now, which is shared with the various modules and web projects.

The reason I am using XML is that I use XSLT to render the navigation hierarchy which gives me huge flexibility rather than having hundreds of module options
# D3grade 8/1/2007 11:40 PM
gedw99You said tis XML driven - why? Surely the page nodes structure inherent in the SiteStructure is what you want to use to drive it?

I think what he meant to say is that a DYNAMIC XML file is created from the site structure so that he can use XSL to style it however he pelases.
# gedw99 8/9/2007 2:16 AM
Yeh i got it now :)