Jump to content

Recommended Posts

  • Moderators
Posted

HI Nabeel, Dave and Jeff :)

Is there a code snipped to add to the page to make it that you must be logged to to view or access?

I would like to make the pilots list only viewable by members.

Cheers.

Posted
core_navigation.tpl
<li><a href="<?php echo url('/'); ?>">Home</a></li>
<?php
if(!Auth::LoggedIn())
{
// Show these if they haven't logged in yet
?>

<?php
}
else
{
// Show these items only if they are logged in
?>
<li><a href="<?php echo url('/pilots'); ?>">Pilots</a></li> //Place the Pilots link here

<?php
}
?>

<?php echo $MODULE_NAV_INC;?>
<?php
if(Auth::LoggedIn())
{
if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
{
	echo '<li><a href="'.fileurl('/admin').'">Admin Center</a></li>';
}
?>


<li><a href="<?php echo url('/logout'); ?>">Log Out</a></li>
<?php
}
?>

  • Moderators
Posted

Hi Jeff,

Thanks for that but i have that already, if someone hits the pilots list directly it will still show them, what im after is like the Airmail feature if you try to access that you get a redirect to you must be logged in to access this page etc.

Posted

is the pilots page listed in here as well?

<li><a href="<?php echo url('/'); ?>">Home</a></li>
<?php
if(!Auth::LoggedIn())
{
       // Show these if they haven't logged in yet
?>

<?php
}
else

it shouldn't be showing if it isn't, unless I missed something. Let me do a little more searching for you. ;)

Posted

Ah crap. nm on the last post the "Show if logged in" is just the code to show a certain page on the menu. Still looking for you though.

Guest lorathon
Posted

What you need to do is add the entire sheet into the brackets of this

<?php
if(Auth::LoggedIn())
{?>
      //Put the entire sheet here

<?php
}
else
{
echo "You must be logged in to view this page";
}
?>

  • Moderators
Posted

What you need to do is add the entire sheet into the brackets of this

<?php
if(Auth::LoggedIn())
{?>
      //Put the entire sheet here

<?php
}
else
{
echo "You must be logged in to view this page";
}
?>

Cheers Jeff Thats the one :)

Guest lorathon
Posted

No problem guys. And you were close Jeff. It is basically the same snippet. You just have to add it to ever page. The reason is that you could just entire the actual address to the page bypassing the normal navigation bar.

Glad I could help out :D

  • Administrators
Posted

If you don't mind me saying, it's better to do this:

<?php
if(Auth::LoggedIn() == false)
{
  echo 'You must be logged in to view this page!';
  return;
}
?>

No else or other brackets to keep track of

  • Moderators
Posted

Still the same repeat on the pilots list,

This is what im using then its pulling the error formatting from the css.

<?php
if(Auth::LoggedIn() == false)
{
  echo '<div id="error">Please login to view this page.</div></div>';
  return;
}
?>

That extra closing div is only relevant on the ObsessBlue templates

  • 8 months later...
  • Moderators
Posted

Just quickly going back to this Nabeel if i use your way i get a repeat of the login message for the amount of hubs that i have but if i place the page in the brackets that fixes it, is their another way?

Guest lorathon
Posted

Mark,

Place it at the beginning of the module not on the template

Example

public function index()
{
   if(Auth::LoggedIn() == false)
   {
       echo '<div id="error">Please login to view this page.</div>';
       return;
   }
   //do whatever that logged in uses can access or see

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...