> Long rambling questions are often ignored on user lists.
> Its a lot easier for us to answer questions that are directly to the
> point covering one subject. Additionally, it complicates things for
> users searching the mailing list when the subject title includes "and
> other matters" ... so we would actually prefer that you sent 3 concise
> emails with specific targeted questions than one long rambling email
> cover "other matters".
You're right, of course. My apologies for breaking the rules. Now I know
them, I'll conform to them.
> Church Michael R wrote:
> >
> > What I want to do is to display a portlet on EVERY page, no matter what
> part
> > of the portal site is being displayed. As far as I can work out, the
> only
> > way to achieve this is to add the appropriate portlet fragment to every
> PSML
> > file on the portal site. This would work, but what a tedious task that
> would
> > be!
> >
> > Is there a better way to achieve this?
>
> I just read your response to your own email.
> Could you send us a snippet of your layout, showing others how you did
> this? I think we should look into a more formalized way of providing
> this feature for everyone.
Okay. Here it is.
In the header.vm of my layout decoration, I altered the generation of the
Left Navigations Menu Table as follows:
#set($pagesStandardMenu = $site.getMenu("pages"))
:
:
<!-- Left Navigations Menu Table Data -->
#set($navigationsStandardMenu = $site.getMenu("navigations"))
#if(!$navigationsStandardMenu.empty)
<td valign="top" id="leftcol" >
<div id="navcolumn">
#if(!$pagesStandardMenu.empty)
#includeWidgetServlet($pagesStandardMenu)
#end
#includeTimeServlet()
<table cellpadding="0" cellspacing="4" border="0"
width="100%">
#includeLinksWithIconNavigation($navigationsStandardMenu $TOP_TO_BOTTOM)
</table>
</div>
</td>
#end
Note that the only additions are calls to the #includeWidgetServlet() and
the #includeTimeServlet() macros. These are located so as to render a couple
of extra document divisions directly above the standard Left Navigations
Menu.
Then I modified my decorator-macros.vm as follows. First, I added a few new
constants in #defineNavigationConstants():
#* define navigation constants *#
#macro (defineNavigationConstants)
#* Constants for layout orientation *#
#set($WIDGET_BOX = "Widget Box")
:
:
#end
Next, I changed #includeTabsNavigation() so that it carefully ignored any
PSML page with the title $WIDGET_BOX:
#* include tabs navigation component *#
#macro (includeTabsNavigation $_menu $_orientation)
<table border="0" cellpadding="0" cellspacing="0">
<tr>
#foreach($element in $_menu.elements.iterator())
#if($element.elementType == "option")
#set($tabTitle = $element.getTitle($preferedLocale))
#set($tabDefaultTitle = $element.getTitle())
#set($tabName = $element.getShortTitle($preferedLocale))
#if($tabDefaultTitle != $WIDGET_BOX)
:
<as before>
:
#end
#end
#end
</tr>
</table>
#end
Of course, I had to make a similar change to the
#includeLinksWithIconNavigation() macro, to ensure that the PSML page with
the title $WIDGET_BOX doesn't appear in the Left Navigations Menu.
Then I added the necessary macros to include the "Widget Box" as an HTML
fragment above the Left Navigations Menu. Note that the Widget Box is added
if and only if a PSML page entitled "Widget Box" exists in the supplied
$_menu (which is itself the value of $site.getMenu("pages")):
#* include widget box component *#
#macro (includeWidgetServlet $_menu)
#set($WidgetShown = false)
#foreach($element in $_menu.elements.iterator())
#if(!$WidgetShown)
#if($element.elementType == "option")
#set($WidgetTitle = $element.getTitle($preferedLocale))
#set($WidgetDefaultTitle = $element.getTitle())
#if($WidgetDefaultTitle == $WIDGET_BOX)
<table cellpadding="0" cellspacing="4" border="0" width="100%">
<tr>
<td>
<div class="toolgroup">
<div class="label">
${WidgetTitle}
</div>
<div class="body">
<div class="FolderList">
.... your HTML here ....
</div>
</div>
</div>
</td>
</tr>
</table>
#set($WidgetShown = true)
#end
#end
#end
#end
#end
The #includeTimeServlet() macro does a very similar job, but doesn't bother
checking whether there is a PSML page in the $_menu. I.e. the fragment of
HTML is always added to the generated portal page.
The final part of the trick is to generate a PSML page (widget.psml) in the
top-level folder. This page defines its title as <title>Widget Box</Title>.
The page is not marked as hidden (otherwise it won't show up in the "pages"
menu). The widget.psml page also has a <security-constraints-ref> value of
"users".
Now, the Widget Box will be shown on every portal page, provided the viewer
has logged in as a "user". It will not be shown to guests.
The widget.psml page is just a "marker" that signals the header generation
macros to generate a snippet of HTML above the Left Navigations Menu. Of
course, this method falls down if you ever generate a real PSML page with a
title of "Widget Box", but that's easily solved by using a completely
different page title that no-one's ever likely to use.
Now, I know that the inserted HTML fragment is not a portlet. In fact, I
generated a division in the HTML fragment, and got its content updated by
calling a special servlet through XMLHTTPRequest (standard old-fashioned
AJAX techniques). The benefit of this method is that the content of the HTML
fragment can be regularly and automatically updated by use of the JavaScript
setTimeout() function.
Mike Church
Software Engineering
QinetiQ
Bldg Lovell Rm 109
Malvern Technology Centre
St. Andrews Road, Malvern
Worcestershire, WR14 3PS
Tel: 01684 896085
Email: [EMAIL PROTECTED]
Web: www.QinetiQ.com
QinetiQ - The Global Defence and Security Experts.
The Information contained in this E-Mail and any subsequent correspondence
is private and is intended solely for the intended recipient(s).
For those other than the recipient any disclosure, copying, distribution,
or any action taken or omitted to be taken in reliance on such information
is prohibited and may be unlawful.
Emails and other electronic communication with QinetiQ may be monitored.
Calls to QinetiQ may be recorded for quality control,
regulatory and monitoring purposes.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]