[TYPO3-english] page access restrictions redirect

Michael Cannon mc at aihr.us
Thu Sep 15 16:36:27 CEST 2011


Tom,

I'm sorry, forgot to say, add the following TypoScript to your TMENU object creating the menu with access restricted pages.

temp.nav.1 = TMENU
temp.nav.1 {
   wrap = ...
   NO ...
   showAccessRestrictedPages = NONE
}


All the instructions now...


1. In TYPO3 page, set the page properties Access to require login or a user group. Do NOT set the Login Mode.


2. In localconf.php, add...

$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'USER_FUNCTION:fileadmin/scripts/pageNotFoundHandling.php:user_pageNotFound->pageNotFound';


3. In fileadmin/scripts/pageNotFoundHandling.php, add...

<?php
define(LOGIN_URL, "http://www.example/subscribe/login-successful/login.html");
define(NOTFOUND_URL, "http://www.example/");

class user_pageNotFound {
 function pageNotFound($param, $ref) {
   if ($param["pageAccessFailureReasons"]["fe_group"] != array(""=>0)) {
     header("HTTP/1.0 403 Forbidden");
     $url = LOGIN_URL."?redirect_url=" . $param["currentUrl"];
   } else {
     $url = NOTFOUND_URL;
   }

   session_start();
   $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
   session_write_close();

   $c = curl_init();
   curl_setopt($c, CURLOPT_URL, $url);
   curl_setopt($c, CURLOPT_COOKIE, $strCookie);
   $contents = curl_exec($c);
   curl_close($c);

   if ($contents) return $contents;
       else return FALSE;
 }
}
?>


4. Add the TypoScript `showAccessRestrictedPages = NONE` into your TMENU object creating the menu with access restricted pages.

Example:

temp.nav.1 = TMENU
temp.nav.1 {
   wrap = ...
   NO ...
   showAccessRestrictedPages = NONE
}



Also, check out http://blog.team-noir.net/2010/08/mixed-typoscript-snippets-vol-1/.


--
Michael Cannon
President, Aihrus
Italy +39 366 702 7237
US +1 617 539 6072

Professional TYPO3 Support Since 2003
http://aihr.us




More information about the TYPO3-english mailing list