Jump to content
  • 0

Show/hide Buttons Based On Authentication


Jess
 Share

Question

Hello,

 

I am using the JS: Show/hide A Custom Link On Results guide to display links to my datapages based on the user's authentication type (Admin, Teacher, Staff, etc.). I know very little about Javascript. I managed to get hyperlinks to display as text but I was wondering if someone could help me with figuring out how to display images that I can hyperlink to a different page on my site containing my datapages?

 

What I am trying to accomplish is side navigation buttons that appear based on authentication type.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Ok, I ended up using the following to get this to work:

text/javascript">
var cb_boolean = '[@authfield:Faculty_Staff_Table_Admin^]';
if (cb_boolean == 'Yes') 
{
document.write('<A HREF="URL"><img alt="" src="PhotobucketURL" target="_blank"><img src="PhotobucketURL" style="width: 267px; height: 40px;" /></A>
}
</script>

I used photobucket to host the images for the buttons so that they would match the native navigation in our site. It looks pretty nice however I have another problem now. Other than the multiple staff groups, I also have parents and students who have completely separate authentication. Since the parents and students run on separate tables, I have to create separate datapages for the buttons. When I past them all where the buttons need to go, the datapage displays the buttons according to group correctly, however if the user is not in the same authentication table they receive their buttons with a login screen below. The login screen if for the buttons they cannot see from the other tables. Is there anyway to hide a datapage completely if the user is not authenticated in that table?

Link to comment
Share on other sites

  • 0

Hello Jess,

 

You can create a copy of your Authentication and select the "Enable auto-login" checkbox, then you can assign all DataPages, where you want not to display Login Forms.

 

It allows you to hide the login page of the copied Authentication, but if a user logs in with the main Authentication, he/she will see DataPages that are assigned with both Authentication.

 

To hide Login form, edit your copied Authentication, add the "Header & Footer" element, select "Header", click the "Source" button and enter the following code:

<div id="cb-auth-box">

Select "Footer", click the "Source" button and enter the following code:

</div>
<script>
document.getElementById("cb-auth-box").style.display = "none";
</script>

There is the article How to hide multiple Login forms, I have edited this solution to hide the Login Form always.

 

I hope, it helps.

Please feel free to ask details if my explanation is unclear :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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...
 Share

×
×
  • Create New...