Dear David!

I'm also a Magnolia Newbie, so please take my advice with care! Perhaps some 
more experienced users can comment on the validity of my suggestions.


I use Freemarker for my templates, since I can then save them in the 
repository, and see changes immediately, without restarting the servers.
Unless you're doing a lot of custom programming/processing I don't see any 
advantage of JSP over Freemarker.

In FreeMarker, I realized a Horizontal Navigation as follows:

I created a new Node (using the JCR Browser) under the Node of my root page, 
call it "navigation".

Under this Node, I create nodes for each navigation point, with the required 
properties (in my case I need: title, link, hover-image and colour for the 
navigation point). To do this I created a paragraph definition for my 
navigation points, which includes the necessary fields, and a dialog definition 
for editing them.

So, in magnolia terms, if /mainPage is my Homepage, /mainPage/navigation is the 
"content-node-collection" and /mainPage/navigation/00, /mainPage/navigation/01, 
etc... are the paragraph nodes for my navigation points.

In every page template, I then include template code which looks like this:

----snip----
1. [#assign mainN=mgnl.inherit(content).navigation]
2.
3. [#list mainN?children as kid]
4.      [[email protected] contentNode=kid /]
5. [/#list]
6. 
7. [#if content?parent?? && content?pare...@handle=='/']
8. [[email protected] contentNodeCollectionName="navigation" 
paragraph="mainNavLink,mainNavLink_external" newLabel="Neuer 
Haupnavigationspunkt..." /]
9. [/#if]
----snip----


In line 1, I use the "mgnl" object's "inherit" function --> this is the key for 
what you need. mgnl.inherit(contentNode) searches the given content node for a 
named content, and if it cannot be found, continues searching in the parent, 
the grandparent, etc..., down to the site root. If one of these nodes contains 
the named sub-node, it returns the sub-node found.
So mgnl.inherit(content).navigation starts at the current node ('content') and 
searches it and its ancestors for the child node 'navigation'. Since it is 
defined on the root-node, that is what is returned.

Next, in line 3, I simply iterate over the children of the navigation node (the 
navigation-point paragraphs) and render each one as a paragraph (line 4), using 
its own paragraph template.

Finally, in line 7 I perform a check to see if the current node is in fact the 
root-node of the site. If so, I show a new-bar (line 8) for adding new 
navigation points. I only show this on the root page, so that the navigation 
can only be edited on the root page. Otherwise adding new navigation points in 
sub-pages would create a new collection node "navigation" in the sub-pages, 
which would then be found by mgnl.inherit(), overriding the navigation defined 
on the root node.

Hope this helps you, and sorry for using Freemarker rather than JSP syntax...

Regards from Vienna,

Richard Unger





-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] 
Im Auftrag von Dave Shaw
Gesendet: Mittwoch, 07. April 2010 15:46
An: [email protected]
Betreff: [magnolia-user] Pulling content from a parent page


I am new to magnolia and JSP so please expound on your replies. My goal is
to reproduce a horizontal navigation bar on the child pages of the home
page. Does anyone have a code snippet to show me how this is done?

Also...

Using the Tools > JCR Browser (Website) menu selection I can expand my
website tree and view the pages (folders) and subpages (folders) as well as
properties of pages (content nodes & node data). I would also like to access
a node data of the home page (folder object) which is an image for my
branding of the site that I would also like to reproduce on each child page.
Does anyone have a code snippet that shows me how to do that?

Thanks for the help.

Dave Shaw


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------




----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to