You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Joe Grist <jo...@andersonmorgan.com.au> on 2005/10/25 01:31:55 UTC

"In This Section" Menu

I have added a new bit to the wiki.  Just letting people know incase it is
useful.  It's under http://wiki.apache.org/lenya/HowToFullyCustomMenus
again.

Its on how to create a new kind of menu for your site pages.  It lists all
the pages immediately below the current page in the heirarchy under the
heading "In This Section". If there are no pages immediately below the
current page, it disappears. This is an extremely useful bit of code I find.
 
Joe Grist
Anderson Morgan Consulting Pty Ltd
PO Box 141 New Town 7008
6278 3387 / 0400 887 081
Joeg at andersonmorgan dot com dot au / www.andersonmorgan.com.au 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: "In This Section" Menu

Posted by so...@gmail.com.
On 10/24/05, Joe Grist <jo...@andersonmorgan.com.au> wrote:
> I have added a new bit to the wiki.  Just letting people know incase it is
> useful.  It's under http://wiki.apache.org/lenya/HowToFullyCustomMenus
> again.
>
> Its on how to create a new kind of menu for your site pages.  It lists all
> the pages immediately below the current page in the heirarchy under the
> heading "In This Section". If there are no pages immediately below the
> current page, it disappears. This is an extremely useful bit of code I find.

Here is a much simpler solution.  There are no changes to the XMAP or
menu.xsl.  It only requires changing page2xhtml.xsl, and most of the
code could be put in a separate file for easier maintenance.

Put this line in your page2xhtml.xsl:
            <xsl:apply-templates select="xhtml:div[@id = 'menu']"
mode="section"/>
where you want the section menu, and these matches near the bottom:

<xsl:if test="xhtml:div[@class='menublock-selected-1']/xhtml:div[@class='menublock-selected-2']|xhtml:div[@class='menublock-selected-1']/xhtml:div[@class='menublock-2']">
  <xsl:copy>
     <xsl:apply-templates mode="section"/>
  </xsl:copy>
</xsl:if>
</xsl:template>

<xsl:template match="xhtml:div[@class='menublock-selected-1']" mode="section">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()" mode="section"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="xhtml:div[@class='menublock-1']" mode="section"/>

<xsl:template match="xhtml:div[@class='menuitem-selected-1']|xhtml:div[@class='menublock-selected-1']/xhtml:div[@class='menuitem-1']"
mode="section">
<div class="menuitem-selected-1">In This Section</div>
</xsl:template>

<xsl:template match="@*|node()" mode="section" priority="-1">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()" mode="section"/>
  </xsl:copy>
</xsl:template>


The first match copies the menu div and passes the mode lower.
- Remove the xsl:if to always show the section menu even when there
are no lower levels.

The second match copies the menublock-selected-1 div and passes the mode lower.
The third match removes the menublock-1s.

The fourth match changes the menuitem-1 to "In This Section".
- Make it an empty match if you do not want any title.  You could add
static text (like "In This Section") directly in your HTML, but it
would not disappear if there were no lower documents.
- Remove this match if you want the title of the section to appear and
be a link when on a lower document.
- Use <div class="menuitem-selected-1"><xsl:value-of
select="."/></div> if you want the title to appear, but never as a
link.

The fifth match copies everything else.

---
Some more work could change the class names to use different CSS than
the regular menu so both can appear on the same page.

If you want to use this code in several page2xhtml.xsl files, put this
code into common-section.xsl and use:
<xsl:import href="common-section.xsl"/>
and the placement line in your page2xhtml.xsl files.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org