Accessing Node Variables

Why can I access some node variables and not others


$node

Displays: 
com.percussion.services.contentmgr.data.PSContentNode@2f6e54[sys_id=727,name=Embry-RiddleStory,depth=2,type=rffNavon] 

---
$node.name

Displays:
Embry-RiddleStory

---
$node.type

Does not return a value

---
$node.depth

Dispalys:
2


I need to be able to access the node type, I have tried doing

#set($navtype = $sys.item.getPrimaryNodeType().getName().toLowerCase())##

But this just gives me one node (rx:rffnavon), not the current node. I ultimately want to find if the node is a navtree and if it is, then reset the depth to 1.

Try…

#if($node.definition.name == "rx:rffNavTree")

…where $node is an element in an array returned by a call to the getNodes() method. Or…

#if($sys.item.definition.name == "rx:rffNavTree")

…to test the item currently being assembled by the snippet template that your code is in.

The answer to your original question (about node properties) is that this is a Nav Node (if depth > 0, that is guaranteed).

The Nav Node is implemented as a “proxy” in front of the regular node. Apparently, there are some methods/properties that don’t get passed through. If you find any useful properties that are not implemented, please post them, and we’ll see if we can get them addressed.

Dave

Now who can argue with that?

Thanks for your responses,

Andrew’s suggestion worked.

The reason I am trying to get the navigation type is to work around the problem with having a site within a site (or sub-global template). I really don’t want to create another site for a simple global template change (a couple of pictures change in the header and navigation reset to start at the current folder). I am not sure if this approach will work but I need to find a way to accomplish this.

Maybe I missed this part, but you’re supposed to be able to set the global template at the folder level. You should not need any complicated code to change to a different global template.

If that isn’t working, then we need to understand why.

Dave

In my linked post below I found that you cannot simply link any global template, only global templates associated with an existing site. I was under the same impression…

I have started thinking about a solution to this problem and would like some input on the best way to solve it. As I mentioned before, the only thing changing in these sites would be the top navigation menu and header/footer graphics, I believe I can handle this change by accessing the parent navtree properties (not the site.root method used in the EI and CI implementations).

The first problem I would like to solve is how to reset the template that creates the top navigation for the site, mine is called “erauSnNavTop”.

existing erauSnNavTop code:


#set($toplevel = $nav.root.getNodes("nav:submenu"))##
html>
	body>
                ul>
			#foreach($navon in $toplevel)
                                  #set($title = $navon.getProperty("rx:displaytitle").String.toUpperCase())##
                                  #set($landing_page = $navon.getProperty("nav:url").String)##
                                  #set($axis = $navon.getProperty("nav:axis").String)##
				  #if($landing_page)li class="firstlevel">a class="$axis" href="${landing_page}">$title/a>/li>#end##
                         #end
		    /ul>
	/body>
/html>

In testing, I can successfully create a new navtree element at the top level within a site and use the existing erauSnNavTop template, however this does not work if I embed the navtree under another navtree, which makes sense since I am accessing the nav.root properties. I would like to change the template to get the nav:submenu nodes from the parent navtree content item (not the nav.root content item). What would be the best way to search for a parent navtree item?

I am thinking I could loop through the nav.root nodes to search for another navtree item? Is there an easy way to do this based on a parent/child relationship?

I was alternatively thinking I could query the rffnavtree content type where site.name = $site.name and depth > current depth of navon items…

Anyone have any ideas? Thanks for your help.

You state that it works unless you “embed the navtree under another navtree.”

What is the purpose of doing this? We intended that you would have 1 NavTree item at the root of each site, and then Navon items underneath it. If you add the property to the NavTree content type, you should be able to access it with
$nav.root.getProperty() (and $nav.root.hasProperty()).

What part are we missing here?

Dave

Dave,

Earlier in the thread I mentioned that the only thing changing with this site is a small header graphic and resetting the top navigation. If one navtree per site is the requirement then we will be creating a new site for each campus, college, and department within the site (each campus has many colleges and each college contains many departments).

Like I said, there are very small changes in the template that allow these sites to appear to be unique but could be handled by calling css classes based on navtree properties. I am also trying to avoid having users that need to switch communities to edit their content.

In my first attempt at getting this problem solved I tried using the folder properties to change the global template but I found that each global template must be used in a site before it appears in the dropdown list of available global templates.

So you are saying that standard way to accomplish this request is to create each in a new site?

I don’t see why you need a new site (and a new navtree) for each section if the only difference is an image and some other small changes. In fact, I don’t see why a separate global template is needed, either.

I would add the image (call it a “section image”) to a new slot on the Navon and the use something like the “propagating slot” macro (see http://forum.percussion.com/showthread.php?t=2562) to find the nearest section image and display it.

You may need an additional field or two ON THE NAVON, and if you add fields to the Navon, you usually will find it simpler if you add them to the NavTree as well. I would not build a single tree with multiple NavTree items.

Maybe I’m missing something about the complexity of your implementation.

Dave

The top navigation for these special sections needs to change, basically a breadcrumb is then created in the header with a new picture to get back to the other section. Here is how the top navigation would change:
[ul]
[li]Campus Section Top Nav: Degrees and Programs, About the Campus, Admissions, Student Life, Financial Aid, Campus Services[/li][li]College Section Top Nav: Degrees, Departments, Students & Learning, News & Events, Faculty, Research, Careers, Alumni[/li][/ul]

Resetting the navigation is I believe what you are missing.

If you set up your site tree so that it matches the navigation of the various sections:
[ul]
[li]Campus Section
[/li][LIST]
[li]Degrees and Programs
[/li][li]About the Campus
[/li][li]Admissions
[/li][li]Student Life
[/li][li]Financial Aid
[/li][li]Campus Services
[/li][/ul]
[li]College Section:
[/li][ul]
[li]Degrees
[/li][li]Departments
[/li][li]Students & Learning
[/li][li]News & Events
[/li][li]Faculty
[/li][li]Research
[/li][li]Careers
[/li][li]Alumni
[/li][/ul][/LIST]

You could then build your top nav so that it uses the Second level folder navons (e.g. Degrees and Programs, About the Campus, etc) to build the top nav. There’s nothing in the code that requires the “root” of the top nav to be a NavTree. You’d still have only one NavTree (in the site home page) and each of the sections below it (Campus, College, etc) would have a Navon, not a NavTree.