How to hide certain pages. Options
ChristophS
Posted: Monday, February 18, 2008 12:03:33 PM
Rank: Devotee

Joined: 2/4/2008
Posts: 38
ChristophS
Posted: Monday, February 18, 2008 12:08:07 PM
Rank: Devotee

Joined: 2/4/2008
Posts: 38
I'm sorry, for the first post (haven't been around too long on this forum).

I have a question about hiding certain pages in Umbraco. I know this is possible and it is already implemented on my site: so certain pages are redirected to the login page if they're not logged in.

Now my question is how to hide pages when you not need to be logged in. Because I have a login/register/pass reminder page. But these pages only need to show up when needed, so when a visitor visits a page for which a login is required to view it. Now what I need to do is hide these login pages etc. from my sitemap and from the subpages listings.

Anyone has an idea how I can do this?
For my sitemap I'm using the following code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:msxml="urn:schemas-microsoft-com:xslt"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="msxml umbraco.library">

        <xsl:output method="html"/>

        <xsl:param name="currentPage"/>
        <xsl:variable name="maxLevelForSitemap" select="6"/>
       
        <xsl:template match="/">
                <div id="sitemap">
                        <xsl:call-template name="drawNodes">
                                <xsl:with-param name="parent" select="$currentPage/ancestor-or-self::node [@level=1]"/>
                        </xsl:call-template>
                </div>
        </xsl:template>

        <xsl:template name="drawNodes">
                <xsl:param name="parent"/>
                <ul>
                        <xsl:for-each select="$parent/node">
                                <li>
                                        <a href="{umbraco.library:NiceUrl(@id)}">
                                                <xsl:value-of select="@nodeName"/>
                                        </a>
                                        <xsl:call-template name="drawNodes">
                                                <xsl:with-param name="parent" select="."/>
                                        </xsl:call-template>
                                </li>
                        </xsl:for-each>
                </ul>
        </xsl:template>
</xsl:stylesheet>
drobar
Posted: Monday, February 18, 2008 2:14:00 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,285
Location: KY, USA
The defacto convention for hiding pages from the navigation is to create a "True/False" docType property with Name of "Hide page?" and an Alias of "umbracoNaviHide".

True/False properties default to false, so all your pages will be visible unless you specifically set them to hidden.

Once you have the property in your docTypes, you need to update your xslt's to check for this property and its value. You will often see an xslt's select statement include the following: "... and string(data [@alias=umbracoNaviHide]) != '' "

For your sitemap, simply create a new XSLT file (don't bother to create the associated macro) and select the "sitemap" template from the drop-down list when you create the xslt file. That sitemap template has the check for umbracoNaviHide in it already and you should be able to retrofit your existing sitemap based on what you see in the sitemap template.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
ChristophS
Posted: Monday, February 18, 2008 4:38:55 PM
Rank: Devotee

Joined: 2/4/2008
Posts: 38
Thank you. Work just fine :).
spacecowboy
Posted: Monday, May 12, 2008 1:34:05 PM

Rank: Newbie

Joined: 5/12/2008
Posts: 9
Location: Wallowing in self-pity

Hi, apologies in advance for the general noobishness of this question, but I get the doctypes bit and that works fine but you mention that you have to do something in the xslt's - Could you please be a bit more specific? Which xslt's and where do we find them? The ones in the developer/xslt folder didn't appear to relate to page rendering or controlling.

Thanks in advance :)
warren
Posted: Monday, May 12, 2008 2:01:11 PM

Rank: Addict

Joined: 7/19/2006
Posts: 716
Location: Leigh-on-Sea, Essex, UK
Hi Spacecowboy.
The XSLT's you need to modify will be specific to your site (as we don't know how you have implmented it), but to hide pages it will most likely in your site navigation XSLT and possibly a sitemap XSLT.

Below is a snippet that lists all nodes that are at level 1 where the property umbracoNaviHide on the document type is set to 1 (aka true)

Code:

<xsl:for-each select="$currentPage/ancestor-or-self::node [@level=1]/node [string(./data [@alias='umbracoNaviHide']) != '1']">
<!-- do what you want here for each navi item -->
</xsl:for-each>



//Warren

Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.