Jump to content

Recommended Posts

I searched and didn't find anything near what I was looking for.  Here is my issue:

It's a website that deals with four basketball teams.  Each team has its own schedule, and I'm making them register to view some parts of the site.  When they register they can choose which Membergroup/team they are with.  I would like for them each to see their team's schedule when they visit the home page.

I have hide/show toggles with onMouseDown commands for me (to be able to see all four), but what I can't seem to get to work is a code the differentiates which team they are on and shows the proper schedule as they visit the home page.  I've tried php code in the style script, as well as separate onLoad commands.  Neither worked.

Thoughts?

Link to comment
https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/
Share on other sites

if you are looking for custom content, depending on who goes to your site, you're going to have to at the very least set a cookie to hold the data so that your script can access the cookie and see which team they are on. 

Or if you have some kind of login system already in place, it's as simple as adding an extra column  to your table.  Or perhaps you already have that info in your database, and it's just a matter of pulling it out and building your page based on that?

Well, that's about as much advice as I can give, without some more info. 

Hope that helped.
Ninja,

Thanks for answering.

I'm using SMF actually and already have registration, cookies, membergroups, and permissions set up.  I'm using their membergroup and permission structure across my site.  I can easily set up code to control which pages they get to or what information to see, EXCEPT hiding and showing layers based on what membergroup they are with.

If they are with SS2008, I want them to see SS2008's schedule.  If they are with SS2011, I want them to see SS2011's schedule.  IS2008 and IS2011...the same thing.  I have four different schedules, each in their own layer.  I want PHP to read what group/team they are wish and display the appropriate schedule.
$groupid = "however you get the group ID";  // so get the groupid of the user, probly stored in the smf session vars?

select * FROM shedules WHERE groupid = $groupid  // do a mysql select for the correct shedule, give your shedule table a groupid column

then display the database details. this will then show the correct shedule based on groupid

Maybe I'm not explaining myself clearly enough.  The schedules aren't in a database.  They are just put in a table in a layer.  Right now all four layers are set to "hidden".  I just want the code to determine which group the user is in, and from that determine which layer to "show".

Something like this:

[code]
if (in_array(9, $user_info['groups']))
  {
echo 'showHideLayers(\'ss2008\',\'\',\'show\')';
  }
[/code]

Only it's not working.  Instead of executing the code it just prints:  showHideLayer('ss2008', ' ', 'show')';

Hi,

Try something like this
[code]<body onload="MM_showHideLayers('rollover','','show','kids','','hide','sport','','hide','bloodsugar','','hide','weightloss','','hide','diabetics','','hide'<?php if (isset($_SESSION['countout'])){if($_SESSION['countout']<=1){echo ",'loginuser','','hide','welcomeuser','','hide'";}}?>)">[/code]
Lovemy,

I appreciate your efforts, but none of those php settings apply to what I need and I can't make heads or tails of them.

Certainly there has to be a way to take a normal hide/show script and place it within PHP.  I already have access to cookie and sessions.  In the code I provided, I'm able to determine which group the user is with.  From there I just need it to determine which layer to show and which layer to hide based on the group they're in. 
Hi Jim R,

Sorry I made an assumption on your skill level... here is a fully working page you can build on.
[code]<?php

//Find out the group and set to $group
$group =3;//This could be from a DB or Session variable
//Now Set up the Show Hide string for the <body> tag
if($group == 1) {$Showhide = "MM_showHideLayers('group1','','show','group2','','hide','group3','','hide','group4','','hide')";}
elseif($group == 2) {$Showhide = "MM_showHideLayers('group1','','hide','group2','','show','group3','','hide','group4','','hide')";}
elseif($group == 3) {$Showhide = "MM_showHideLayers('group1','','hide','group2','','hide','group3','','show','group4','','hide')";}
elseif($group == 4) {$Showhide = "MM_showHideLayers('group1','','hide','group2','','hide','group3','','hide','group4','','show')";}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<!-- Deamweaver show/hide Javascript //-->
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//-->
</script>
</head>
<!--now we echo the $Showhide string withing the double quotes of the onload param -->
<body onload="<?php echo $Showhide?>">
<div id="group1">Group 1 DIV</div>
<div id="group2">Group 2 DIV</div>
<div id="group3">Group 3 DIV</div>
<div id="group4">Group 4 DIV</div>
</body>
</html>
[/code]
This is the way I would do the deed.

Lovemy7 (The 7 refers to my Lotus 7)
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.