authentication - Sitecore - Prevent access to a page, but still show it in the navigation


Question: 

In Sitecore I have denied access to a particular page for the anonymous user.

This works correctly, but it also means that the page does not appear in the navigation menus and sitemap (both XSLT).

What I would like is for the user to be able to see the link, but be redirected to a Register/Login page when they click on it.




2 Answers: 

You'd need to allow anonymous users to view the page for it to be visible in the menu and sitemap.

What you could do though is override the Sitecore.Pipelines.HttpRequest.HttpRequestProcessor to check if the page requires a login (by adding a RequiresLogin True/False to the template for example), then check if the user is logged in if not redirect to your login page.

Theres an example of overriding the HttpRequestProcessor here

 

You could wrap the rendering logic in the menus in a SecurityDisabler, so it would render all item links, even if the user "cant see" them.

using (SecurityDisabler disabler = new SecurityDisabler())
{
  foreach (Item item in Sitecore.Context.Item.Children)
  {
    ... render the link ...
  }
}
 

More Articles


Dose google play count insalls out of itself downloads?

I recently published my app in google play . The question is how google play show counts ?1 - All device that have google play installed and my apps too , total count of my apps install will show in play store .2 - Just all downloads that directly are downloaded from google play will be count .

apache spark - Scala - How to iterate over tuples on RDD?

I have an RDD that contains tuples like this (A, List(2,5,6,7)) (B, List(2,8,9,10))and I would like to get the index of the first element where a specific condition between value and index holds. So far I have tried this on a single tuple test and it works fine:test._2.zipWithIndex.indexWhere

email - PHP mail function not working based on the body of the message

so on my server I tried running:mail('my@email.com', 'asdf', 'asklfdjksalfdsdaf I know I I know I');and PHP sent the mail perfectly....but then when I changed the message to mail('my@email.com', 'asdf', 'hahahahaa');it did NOT send the email to me....what can possibly cause this? the only thing that


Computer Networks ip addressing

So I have this exercise in one of my classes on network ip addressing. The problem is that i cant figure out how to complete the subnet bits and hosts bits..can anyone help me?the number of hosts is 414, 189, 135 and 90...

javascript - less.js: Use custom import function

less.js is using an internal xhr() function to load @imported .less files dynamically via ajax.I want to know if there is anything I can do the hand a custom function over to the less parser to get the imported files loaded through this function and NOT through the default loading function.As a wild

scala - Should I use collectionAsScalaIterable({java collection}) or Seq({java collection}).flatten?

We're starting to use Scala Test to test our Java application, and I want to test the contents of a Java Collection. We came up with 2 possibilities:JavaConversions.collectionAsScalaIterable(getJavaCollection()) must contain(allOf(item1, item2).inOrder)orSeq(getJavaCollection()).flatten mustEqual Se


Revert from Python 2.7 to Python 2.6 in Mac OSX 10.6.8 doesn't work even though I've uninstalled Python 2.7

I have mac OSX 10.6.8. My system came with Python 2.6I recently installed Python 2.7 but experienced many problems with it so decided to revert back to Python 2.6 by executing $ sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7I also removed Python 2.7 from my Applications folder. Still

How do I access my website (IIS) from the internet?

I have installed IIS. I have browsed to my website on IIS using the 'Browse *:80 (http)' link in IIS. This navigates to http://localhost. That link is only going to work on my own machine.I don't care about my IP address changing (I'm going to show my website for a few hours max every now and the

plone - How can I get rid of spam users

The company I work for have a small Plone blog. But we have a problem with spam accounts. We use captcha on the site and Plone sends a mail to the users that they must confirm before they can edit the user profile. Still about 600 spam users are created every day. In the Plone user profile they past

python - sklearn.KNeighborsClassifier gives very low accuracy score

I am new to machine learning.I created a data, random numbers in two sets. I am trying how to find a sample, however when doing following, I receive very low accuracy score:from random import randint as Rfrom matplotlib import pyplot as pltimport numpy as npfrom sklearn.neighbors import KNeighborsCl