Showing links to protected areas

Author Message

Nathaniel Fitzgerald-Hood

Tuesday 17 February 2004 9:56:37 pm

Hi,

I have a main list of folders for a site which makes up the main menu. One requires authenticated access, so it doesn't show in the list unless a logged in user visits the site. How can I have the item show in the list even when an anonymous user visits resulting in it prompting for login?

Is there something I can supply to the fetch? If I hardcode the link it doubles up the link (1 is hardcoded, the other is from the fetch) when an authenitcated user visits the page. Or, do I need to test for a logged in user and not show the link twice manually?

Mark Marsiglio

Monday 13 June 2005 9:57:09 am

I am having this exact problem. Did anyone ever determine a solution? I need to show the links to content so that non-members get excited about the things they can't access, at which time they are redirected to a login/join page.

Seems like there should be a way to have the fetch ignore the permission/roles.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Xavier Dutoit

Tuesday 14 June 2005 12:14:09 am

A fetch that ignore the access right would be a big security problem. However, you can do that from an extension at the php level if you wish.

Anyway, the easiest solution (well, the one I use) is to test if the user is anonymous. If he's, then display the hardcoded link, otherwise, don't has it will be displayed from the regular fetch.

X+

http://www.sydesy.com

Mark Marsiglio

Wednesday 15 June 2005 1:53:08 pm

I ended up creating a solution for this, by modifying the pagelayout.tpl to show a message in place of the content if it is in the Members section.

The anonymous user has access to the member section, but the content display is limited by the template.


{* Determine if this page is in the Members section, and if not, show it normally *}
{section show=ne($module_result.section_id,6)}

   {$module_result.content}

{section-else}

{* If it is in the members section, determine if the user is logged as a member of the group which has access rights, and if so, show them the content normally *}
						
{let current_user=fetch('user','current_user') }
{section show=eq($current_user.contentobject.main_parent_node_id,157)}

                     {$module_result.content}

{section-else}

{* If the content is restricted, and the user is not logged in, display a message in place of the content *}

<h1>Sorry, this page is restricted</h1>

<p>The page you have requested is reserved for <b>FAIFA members only</b>. To take advantage of this and all of the other valuable benefits of members, please consider joining FAIFA. </p>

<p>If you are a current member, you may <a href="/user/login">log in here to access this page</a>. If you are a current member but do not have your user ID or password, please <a href="/contact_us/">contact us to request a user ID and password. </a></p>

{/section}

{/let}

{/section}

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.