Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

page content based on which member is logged in

Asked Modified Viewed 1,877 times
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
asked
Junior Member

I am using airtable to store/manage data for my job. I have a team of 4 people. In airtable we have the ability to create a calendar view that can be embeded on my site. I have a calendar view for each member. I want to create a "Calendar" page on my site that contains all 4 calendars but i want to be able to make it to where it only shows the calendar for who is logged in. Is there a way to make an "IF / Else IF" statement so that Member 1 only sees his calendar and member 2 only sees his calendar, etc? I have done some searching and havnt been able to find what i need. If there is already a thread on here that can point me in the right direction i will gladly start with that but i cant find anything. Thanks in advance.

Merged on Jan 25 2018 at 20:18:51:
So far i have tried this and several other things but cant seem to get it to work. I am sure its something simple that i am missing.

<?php if (.$userdata['member1']); ?>
<iframe class="airtable-embed" src="Calender for member 1" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php elseif (.$userdata['member2']); ?>
<iframe class="airtable-embed" src="Calender for member 2" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php endif; ?>

I am no expert at coding but usually i can work my way around most issues and im sure if i continue digging i can figure this out but so far i havnt had any luck. I know that i can just create separate pages for each calendar but i want to be able have 1 Calendar page that contains all 4 calendars but only shows the calendar associated with the user logged in if that makes since.
Edited by shornsby on 25-01-2018 20:18,
0 replies

12 posts

G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

Try something like this:
<?php
if(iMEMBER) {
$result = dbquery("SELECT * FROM ".DB_USERS." WHERE user_id='".$_GET['user']."'");
if (dbrows($result)) {
   $data = dbrows($result);
$member = $data['user_name'];
if ($member == "Joe") {
echo '<iframe class="airtable-embed" src="Calender for member 1" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>':
} elseif ($member == "Fred") {
echo '<iframe class="airtable-embed" src="Calender for member 2" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>':
} elseif ($member == "James") {
echo '<iframe class="airtable-embed" src="Calender for member 3" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>':
} elseif ($member == "Ralph") {
echo '<iframe class="airtable-embed" src="Calender for member 4" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>':
      }
   }
}
?>
Edited by Grimloch on 25-01-2018 23:44,
0 replies
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Junior Member

Thanks Grimloch, i will give that a shot as soon as i am done updating phpfusion.
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

Cool ! Notice that I added some code which only lets this run if it's a logged in user. Are you doing this as a custom page or what?
0 replies
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Junior Member

I see that, one thing i do want to ask though is the "iMember", will that work with admins or super admins as well? And yes i am just creating a custom page for this to go on. My update to 9rc4 failed so i had to restore my site. i will try it again later on but for now im going to leave it as is lol
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

Yes. Admins and the Superadmin have access to everything, always. I don't want to detract from all the hard work that the Fusion Team is doing here but if you want my honest opinion, I'd personally stick with 7.02.07. It's solid as a rock.
0 replies
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Junior Member

That doesn't work. Because the iframes are html and not php, do we need to separate the php from html code? As far as upgrading to 9, i am probably going to wait until the final version to come out before trying to upgrade again.

Merged on Jan 26 2018 at 01:23:44:
This is all i get, just the page title. If i remove all the php coding and just have the iframes, the calenders show up. What i am doing isnt really all that necessary as we have the calendars setup on our phones and outlook via "ical subscription". I just want to try and make this work just to do it ya know. The more i do, the more i learn.
Edited by shornsby on 26-01-2018 01:23,
shornsby attached the following file:
screen_shot_2018-01-25_at_62148_pm.png [No information available / 99 Downloads]
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

I would have to see your entire coding to see how to tell you to do it but iframes within php is no problem though I think you'll need to wrap each one in a div. I'm at work now and going by memory cause I can't access my own stuff at home thru this firewall. I'll be able to do more tomorrow.
0 replies
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Junior Member

Ok thank you, just let me know when/if you have time to mess with it. I have played around with it, trying different things from looking at other sites for several hours now tonight and still havnt had any luck. Im calling it quits for now and will mess with it more over the weekend. Thanks again for your help.
0 replies
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

OK, let's get back to it shall we? First if you wanted to try it without php try this:
<?php
if(iMEMBER) {
$result = dbquery("SELECT * FROM ".DB_USERS." WHERE user_id='".$_GET['user']."'");
if (dbrows($result)) {
   $data = dbrows($result);
   $member = $data['user_name'];
if ($member == "Joe") {
?>
<iframe class="airtable-embed" src="Calender for member 1" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php
} elseif ($member == "Fred") {
?>
<iframe class="airtable-embed" src="Calender for member 2" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php
} elseif ($member == "James") {
?>
<iframe class="airtable-embed" src="Calender for member 3" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php
} elseif ($member == "Ralph") {
?>
<iframe class="airtable-embed" src="Calender for member 4" frameborder="0" onmousewheel="" width="100%" height="533" style="background: transparent; border: 1px solid #ccc;"></iframe>
<?php
      }
   }
}
?>

I'm assuming your 'Calendar for member x' is replaced with an actual URL right? Lemme know if this works for you.
0 replies
S
shornsby
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions
answered
Junior Member

Thanks for getting back with me but unfortunately that doesnt seem to work either. I am adding the url for the airtable in the code, i just didnt want it out there for the world to see. I sent you a private message with my website in it if you want to check out what im working on.

Merged on Jan 27 2018 at 05:41:46:
So after going back to the basics... i do know that the following code will display the current username on a page. I created a test page (Test 10) with the following code. once saved and loaded, it does in fact show the current user. Now i just have to figure out how to store the user name to use it in the if statement.

<?php
echo "".$userdata['user_name']."";
?>

Merged on Jan 27 2018 at 06:20:32:
Thank you again Grimloch, could not have done it without you. When i looked at what you got to work i got to thinking that it looks so simple but i just couldnt figure it out lol.
Edited by shornsby on 27-01-2018 06:20,
1 reply
G
Grimloch
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
answered
Senior Member

You are very welcome my friend.
0 replies
D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

In stead of doing a query to select the user, you can use $userdata['user_name'].
The user is logged in and the variable $userdata holds its info.
This is including the userfields.

As alternative use a userfield and enter the path to The correct calender for each user
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 12 posts
  • Votes 0 votes
  • Topic users 3 members

3 participants

G
G
Energy can neither be created nor destroyed; only transformed !
  • Senior Member, joined since
  • Contributed 722 posts on the community forums.
  • Started 141 threads in the forums
  • Answered 2 questions
D
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
S
S
  • Junior Member, joined since
  • Contributed 13 posts on the community forums.
  • Started 3 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet