Jim R Posted January 30, 2007 Share Posted January 30, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/ Share on other sites More sharing options...
ninja Posted January 30, 2007 Share Posted January 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172483 Share on other sites More sharing options...
Jim R Posted January 30, 2007 Author Share Posted January 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172494 Share on other sites More sharing options...
TEENFRONT Posted January 30, 2007 Share Posted January 30, 2007 $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 columnthen display the database details. this will then show the correct shedule based on groupid Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172496 Share on other sites More sharing options...
Jim R Posted January 30, 2007 Author Share Posted January 30, 2007 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')'; Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172505 Share on other sites More sharing options...
ninja Posted January 30, 2007 Share Posted January 30, 2007 I'm assuming that showHideLayers() is a js function you made? you must call it in the same way as you would call normal js. Do you have script code tags echoed before and after that echo? etc.. Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172821 Share on other sites More sharing options...
Jim R Posted January 30, 2007 Author Share Posted January 30, 2007 What I have is at the top of the code. It's recognizing the php and just printing the echo statement. Here is how the js function is called, but I tried that earlier too.onmousedown MM_showHideLayers('ss2008','','show') Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-172930 Share on other sites More sharing options...
Jim R Posted January 31, 2007 Author Share Posted January 31, 2007 ;) bump Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-173651 Share on other sites More sharing options...
lovemy7 Posted January 31, 2007 Share Posted January 31, 2007 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] Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-173685 Share on other sites More sharing options...
Jim R Posted January 31, 2007 Author Share Posted January 31, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-173964 Share on other sites More sharing options...
lovemy7 Posted February 1, 2007 Share Posted February 1, 2007 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> tagif($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) Quote Link to comment https://forums.phpfreaks.com/topic/36278-need-help-with-showhide-layers/#findComment-174456 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.