1
toddarc
Is there a place I can add conditional coding for the start module?
  • 2004/8/20 15:44

  • toddarc

  • Just popping in

  • Posts: 11

  • Since: 2004/8/8 6


Hi folks,

I was wondering if anyone has added code to aim the homepage at a different module if a user is logged in as a webmaster/registered or anonymous user? Right now I've set up blocks based on group permissions, but the site manager has no clue on html coding so would prefer he had the ability to modify start pages through module resources.

So if the above isn't clear, I would like logged-in users (including webmasters) to see TinyD1 and anonymous users to see TinyD2 as homepage content.

Thanks for your time!

Todd

2
m0nty
Re: Is there a place I can add conditional coding for the start module?
  • 2004/8/20 15:59

  • m0nty

  • XOOPS is my life!

  • Posts: 3337

  • Since: 2003/10/24


i don't think anybody has produced such a hack in this regard. not seen anybody actually ask for this requirement either, which is probably why it hasn't been done before.

altho now mentioned it could be a useful hack for someone to make if possible :)

3
toddarc
Re: Is there a place I can add conditional coding for the start module?
  • 2004/8/20 16:19

  • toddarc

  • Just popping in

  • Posts: 11

  • Since: 2004/8/8 6


It wouldn't be as simple as commenting this out (in index.php):

//check if start page is defined
if ( isset($xoopsConfig['startpage']) && $xoopsConfig['startpage'] != "" && $xoopsConfig['startpage'] != "--" ) {
header('Location: '.XOOPS_URL.'/modules/'.$xoopsConfig['startpage'].'/');
exit();
}

and adding this:

if ($xoops_isuser)
{header('Location: '.XOOPS_URL.'/modules/tinycontent/');
exit();
}

else
{header('Location: '.XOOPS_URL.'/modules/tinycontent2/');
exit();
}

would it?

*********Added**********

After some experimenting with the above code, I can alter the module but can't get the "if" statement to act conditionally (or maybe I'm using the wrong variable for a logged-in person). If one of you php'ers could help a bit i'd sure appreciate it!

Todd

4
toddarc
Re: Is there a place I can add conditional coding for the start module?
  • 2004/8/21 1:41

  • toddarc

  • Just popping in

  • Posts: 11

  • Since: 2004/8/8 6


Feel kinda foolish now, should have expected this...

I got the following code to work:

//show proper homepage module for this users group level
global $xoopsUser;
if(!empty($xoopsUser)) {
$group = $xoopsUser->getGroups();}
if ((in_array(1, $group)) OR (in_array(2, $group))) {//user is registered so show member homepage
header('Location: '.XOOPS_URL.'/modules/tinycontent2/');
exit();
}
else {//user is unregistered so show public homepage
header('Location: '.XOOPS_URL.'/modules/tinycontent/');
exit();
}

Now the problem is this - if the visitor logs in or out while on the homepage, the application instinctively returns him to the same page after logging (but of course now it is the wrong module for his group).

Any ideas on modifying the redirect mechanism? Or would it make more sense to undo these mods and set the default module to a one-page module with the above code?

Thanks

Todd

Login

Who's Online

511 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 511


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits