HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


"script" quesitions

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#105169 (In Topic #20508)
Avatar

Fan in action

"script" questions

I'm trying to make a page load or not load, depending on if it's a guest or not.
If it's a guest, it loads
else, it redirects

{+START,{IF,{$EQ,{$IS_GUEST,0}},{$DATE_AND_TIME}}{+END}

^^ that doesn't actually work, and neither does every variation of moving the brackets around.

Has anyone found a way to:

If == Guest
     print page
Else
     redirect to other page


Back to the top
 
Posted
Rating:
#105173
Avatar

Community saint

Try:

{+START,IF,{$IS_GUEST}}
  ...the content you want only guests to see...
{+END}
{+START,IF,{$NOT,{$IS_GUEST}}}
 ...possibly some javascript to redirect to another URL...
 ...or maybe just incorporate the content of the other URL here...
 ...or load the content of the other comcode page here with {$LOAD_PAGE,page_name,zone_name} without redirecting...

{+END}
Back to the top
 
Posted
Rating:
#105175
Avatar

Fan in action

Jason Verhagen said

Try:

{+START,IF,{$IS_GUEST}}
  ...the content you want only guests to see...
{+END}
{+START,IF,{$NOT,{$IS_GUEST}}}
 ...possibly some javascript to redirect to another URL...
 ...or maybe just incorporate the content of the other URL here...
 ...or load the content of the other comcode page here with {$LOAD_PAGE,page_name,zone_name} without redirecting...

{+END}

This works pretty good, thanks. One little detail about it that I'd like to find a solution to, though. So,
{$LOAD_PAGE,page_name,zone_name}
works very well, but it redirects the page correctly, but minus the left and right panels.
I've tried several variations of the target, but it still redirects to the indicated page, but without the left and right panels.
I tried creating a blank dummy page, and having LOAD_PAGE point to that, and then have the ocp Redirect admin tool Redirect the dummy page to the correct page, but that didn't fly.
It's almost perfect, but the side panels are missing for some reason, no matter which page I redirect to. or the redirect to the forums, it does redirect there, but minus some of the top statistics information.

Any more ideas on this, to include the left and right panels?
Back to the top
 
Posted
Rating:
#105355
Avatar

Community saint

I'll have to give this one some more thought. Other than using some javascript in the non-guest part of the page to redirect the browser for members, I'm not sure what else to try for redirecting. In a comcode page, some javascript like this:


[html]
<script>
window.location.assign("http://www.yourwebsite.com/the_url_to_redirect_to")
</script>
[/html]

Be sure to include the [html] and [/html] comcode tags. If you are not editing the site with an Admin account, the usergroup of the account you edit with should have the Use Dangerous Comcode privilege enabled (Admin Zone->Security->Privileges->Comcode). 

I prefer not to use redirects in this way and instead (whenever possible) try to re-work the menus, links, and flow of navigation so members would never see or get to the pages that were intended only for guests and guests would never see or get to the pages that were intended only for members. For example, if the link to the page you are trying to add the redirect to is on a menu, you can split the page into two pages (a guest-only page and a members-only page) and add both pages to the menu, making sure the Only Display If Has Permission option is checked in the menu editor for each of the new page links. You should then be able to use permissions on each of the pages to restrict which usergroups can access them. That should then restrict the link visibility of the links on the menu to the proper usergroups. If not, there is also a Restrict Link Visibility option in the Advanced section of the menu editor that can be used.
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: