How To Show Alternate Menus By Page
This content was moved to its own page from the Questions page.
NOTE: This content refers to the old-style XSL Layouts, which have long since been replaced. This content will not apply to most EditMe sites.
Q.[Tom] I would like to set my Wiki up so that different pages can have different menus. I've seen some of the postings here regarding that issue but I don't think they apply to what I'm trying to do. Basically, Users will be taken to my site from a location outside of the Wiki and will be asked to log in or register. For example, one link to the site may look like this:
http://www.mywiki.com/Product1 and another link may look like:
http://www.mywiki.com/Product2
I don't want users visiting the Product1 area to see any Nav Menu items that would take them into the Product2 area and vise-versa.
I don't want to have to go into the Admin account and grant access privs to each user for the particular site that they are interested in and even if I did, how would I know which site to grant them access to?
Using the un-registered vs, registered user tip won't work in this scenario.
Could I use some Javascript code in the XSL file to detect if the "Product1/Product2" string is present in the referencing URL and include the appropriate menu page?
A. [matt] Tom, the easiest way to do this would be to have two different EditMe sites! But it can be done in one site using an "choose" statement in the XSL layout. This might look something like this:
<!-- This inserts the contents of the Menu page. --> <xsl:choose> <xsl:when test="page/page-id = 'Product1'"> <xsl:value-of select="menus/menu1/page-content" disable-output-escaping="yes"/> </xsl:when> <xsl:when test="page/page-id = 'Product1'"> <xsl:value-of select="menus/menu2/page-content" disable-output-escaping="yes"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="menus/menu/page-content" disable-output-escaping="yes"/> </xsl:otherwise> </xsl:choose>
This will show the page called Menu1 as the menu when viewing the Product1 page, or the Menu2 page as the menu when viewing the Product2 page, or the normal Menu page when viewing any other page. Note that only pages whose names begin with "Menu" are available for insertion like this. We can also help you set this up if you have troubles with it.