Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# markfind 4/21/2009 5:02 PM
I have realized that modules attached to a template doesn't have the Section.Node property filled and they are really a module-linked to the template. base.Section refer to a Section not bound to a node. so it is really difficult to get the current node (page) for the page.

Is querying the sectionUrl the only way to obtain current node?

Marco
# martijnb 4/22/2009 8:50 AM
In the codebehind of module controls you can always do something like:
Node activeNode = ((PageEngine)this.Page).ActiveNode;
# markfind 4/22/2009 9:48 AM
Martijn, I think this is a bug, because attacched sections doesn't have a context (references to the current node).

So, we can add the code you have post to the LoadContent method (PageEngine.cs):
				// Load sections that are related to the template
				foreach (DictionaryEntry sectionEntry in ActiveNode.Template.Sections)
				{
					string placeholder = sectionEntry.Key.ToString();
					var section = sectionEntry.Value as Section;

					// enforce this to give context to the attached secions
					section.Node = _activeNode;

...


# markfind 4/22/2009 9:55 AM
Also, I found the would be preferable to have an order to the attched sections, as node has order for his sections.

Analyzing LoadContent method adding configured section to a template first load attached sections and after the "normal" sections.

For now I have reversed this order, because deploying a module to a template means not to view it first (think about a feedback control, best at the bottom of the page).

Or, better, set a order out of context (i.e. 0 or 99) and merge sections at the low level, not letting Nhibernate to load them.

Marco
# markfind 4/22/2009 1:56 PM
Ok, there is a simply solution: adding a placeholder after.. All the attached sections, especially if you have to deploy a module site-wide.

Marco