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.


How Would I...?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#27027 (In Topic #6238)
Joe
Avatar

Honoured member

Page viewing permissions

I was interested in an idea for my site, but I'm not sure exactly how I would be able to go about doing so.

Basically what I'm trying to do is make it so when a member visits the welcome part of your site (domain.com), they will be redirected to the members page (domain.com/site). I want it so guests can only view the main welcome page (which I know how to do), and make it so registered members cannot view the main welcome page but be redirected to the members page (domain.com/site (which I don't know how to do)). I was thinking to restrict access to the welcome page for registered members, but doing that (as I would imagine) would give them an error making it impossible to even get access to the members area unless of course they typed in domain.com/site in the url which could be a pain.

Is there some kind of code snippet I could place in the main welcome index page that will redirect members to the members area (domain.com/site)?

Any support is appreciated. Thanks.


Back to the top
 
Posted
Rating:
#27028
Avatar

Interesting problem.

What I'd do myself is I'd use "Single public zone", and then I'd use the 'if_in_group' Comcode tag to output different page contents on the single 'start' page according to usergroup. I'd deny zone access to the 'site' zone for Guests.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#27034
Avatar

Fan in action

Another Suggestion

 I'm sure Chris' suggestion is probably best, but I was having a hard time following it without actually trying it. But here's what I was thinking as I was reading your question:

First, you would re-name your current 'start.txt' page to something else, i.e. 'Guests.txt'. Then create a new comcode page called 'start' and just put some cool, related graphics (etc) on it and 2 links. One link "For Guests Only", which would direct them to www.yourdomain.com/pg/guests which is your "old" 'start.txt'. The second link "For Members Only" would be directed to www.yourdomain.com/site which would require a log in if you set the permissions. You could also set the permissions so that a member could not click the "For Guests Only" link. Make sure you keep your new page in the right folder public_html/pages/comcode_custom/EN etc. or wherever your current start.txt page is now.

So when someone goes to www.yourdomain.com they will come to your newly created page asking them to choose one link Members or Guests. It adds one step for your visitors, but it beats adding to the URL they need to type to get to your site. The only problem I can see is the side menus if you use them, and there is a work around for them as well, if you give it some thought.
 
Back to the top
 
Posted
Rating:
#27036
Avatar

I'll explain mine in a bit more depth, as I was rushing a bit before.

The "Single public zone" option is something presented in the Setup Wizard. What it does is set up 3 transparent redirections for pages (there's an icon for these under the 'Structure' tab of the Admin Zone):
  • It links site:panel_left to :panel_left
  • It links site:panel_right to :panel_right
  • It links site:start to :start
The end effect of this is that the welcome zone and the site zone have the same front page and menus, even though the zones are actually still separate.
You can grant guest access to the welcome zone, which has very little in it (basically, your combined front page, your join page, and your login page). But you deny guest access to the site zone, which has the 'meat' of the website in it.
Now the last thing left is to make it so your 'start' page looks like two separate pages, depending on whether you are a guest or not. The 'if_in_group' Comcode tag is good for this. For example:

Code

[if_in_group="1"]You are a guest. You must [page=":join"]join[/page] before you may access the website.[/if_in_group]
[if_in_group="2,3,4,5,6,7,8,9,10"]Normal front page goes within this Comcode tag.[/if_in_group]


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#27043
Avatar

Community saint

Yeah, what chris said is what I was going to say too.  O_o
Back to the top
 
Posted
Rating:
#27060
Joe
Avatar

Honoured member

Now the last thing left is to make it so your 'start' page looks like two separate pages, depending on whether you are a guest or not.

What exactly do you mean by this, Chris? Do you mean that if a guest visits the site zone, he will be given an error message stating him or her must login first to view that specific zone, and if a member would visit the welcome zone, they would be forwarded to the site zone, correct? This is all a little confusing. Sorry if I made my first post unclear, it was a bit difficult to explain.

Where exactly would I place this comcode tag? When a guest types in your domain name, they would obviously be viewing the welcome page (depending on the single public zone setting Chris stated above) of your website. I'm looking for a way so that when a member types in your domain name, they would view the welcome page (they would obviously need to login first as they would be considered a guest), and after members have logged in, they would be redirected to the site zone.

Even if after a member logs in and types in your domain name (domain.com (which would be where the welcome zone is located)), they would be again, redirected to the site zone. So to chop a few things down:

I know how to restrict the 'site' zone access from guests. I know how to restrict the 'welcome' zone access from members, I just want it so members will be redirected to the site zone after login, and not be able to view the 'welcome' zone from that point on.

I'm sorry if this is all a little confusing, I myself am not totally sure what the heck I'm trying to say. :P


Last edit: by Joe

Back to the top
 
Posted
Rating:
#27062
Avatar

Chris was saying that you should edit the :start Comcode page and include the Comcode he gave you, with a message for guests explaining why they should register, and a message for users directing them to the site zone (with a link). Something like the following:

Code

[if_in_group="1"]You are a guest. You must [page=":join"]join[/page] before you may access the website.[/if_in_group]

Which would display only for guests. Then something like this:

Code

[if_in_group="2,3,4,5,6,7,8,9,10"]You might want to go to the [page="site:start"]site zone[/page].[/if_in_group]

Which would display for logged-in members.

Back to the top
 
Posted
Rating:
#27067
Avatar

I'll take my stab at this, too ;).

Where exactly would I place this comcode tag? When a guest types in your domain name, they would obviously be viewing the welcome page (depending on the single public zone setting Chris stated above) of your website. I'm looking for a way so that when a member types in your domain name, they would view the welcome page (they would obviously need to login first as they would be considered a guest), and after members have logged in, they would be redirected to the site zone.

Maybe it would help if you explained exactly why you want guests to have their own zone. With the solution proposed by Chris, guests would have their own page - nothing more (though you could add more pages that are accessible only to guests, if that's important).

To do this, you start by turning on the "Single Public Zone" option from the setup wizard (or manually set up the transparent redirects as he showed), which leaves you with www.mywebsite.com looking just like www.mywebsite.com/site (even though they are still different zones - the former is simply showing you the content contained in the latter). This, at first, would seem wrong - that you wouldn't want your welcome zone to show the content from the site zone, but hang on. All of your website's 'meat' you keep in /site, which you make inaccessible to guests (in Admin Zone > Structure > Zones), so if a guest tries to cheat the system by typing www.mywebsite.com/site/?page=whatever, they'll get an error message generated by ocPortal.

You then edit your site:start (or :start, I'm not sure which) page to contain:

Code

[if_in_group="1"]You are a guest. You must [page=":join"]join[/page] before you may access the website.[/if_in_group]
[if_in_group="2,3,4,5,6,7,8,9,10"]Normal front page goes within this Comcode tag.[/if_in_group]

What this does is:
  • A guest visiting :start (mywebsite.com) will see the guest message you write
  • A guest visiting site:start (mywebsite.com/site) will get an "access denied" error generated by ocPortal (because you've cut off guest access to the site zone)
  • A member visiting the :start page will see the normal page (since you put it in the proper if_in_group comcode tag, and it's just cloning what he'd see if he went to site:start)
  • A member visiting site:start will see the main page - same as before.

The only problem I still see with this is that guests would be able to see your public left and right menus. To get around this, you could do the same thing to the panel_left and panel_right that you did with your start page, which was to surround it with the right if_in_group comcode tag to hide it from your guests, and to show guests any other message you'd like them to see.

Sorry for the confusion. One of ocPortal's strengths is its flexibility in matters like this, but unfortunately this makes the program inherently more confusing. If you can get a grasp on the details here, however, it will be a very powerful asset.

Let us know if you'd like additional explanations.

Back to the top
 
Posted
Rating:
#27159
Joe
Avatar

Honoured member

Ok. I've managed to create the single public zone. Now for another question:

For page titles, this is what I put:

Code

[if_in_group="1"][title="1"]Welcome to {$SITE_NAME}[/title][/if_in_group]
[if_in_group="2,3,4,5,6,7,8,9,10"][title="1"]TS2S Members Area[/title][/if_in_group]

This does not seem to work. Regardless of your appearance status (guest or member), it shows "Welcome to TS2S" as the title. Is it possible to have two different titles for members and guests? If so, how would I go about doing this (seeing as that comcode tag doesn't work)?

Back to the top
 
Posted
Rating:
#27160
Joe
Avatar

Honoured member

Also, for the left & right panels I wanted it to show only to members. Using that comcode works, but it only makes the blocks disappear. How would I make the entire panel collapse?

Back to the top
 
Posted
Rating:
#27165
Avatar

For this kind of control you'll need to go down to the template level and use Tempcode to change some things.

For the title, no this is one thing that the if_in_group tag won't properly work with, because it's not actually displayed when the tag is placed. Try changing the 5th line of the PAGE_TITLE template to:

Code

   <h1 id="main_page_title">{+START,IF,{$AND,{$IS_GUEST},{$EQ,{TITLE},TS2S Members Area}}}Welcome to {$SITE_NAME}{+END}{+START,IF,{$NOT,{$AND,{$IS_GUEST},{$EQ,{TITLE},TS2S Members Area}}}}{TITLE}{+END}&nbsp;&nbsp;&nbsp;</h1>

For the panels, try changing lines 32-33 of the GLOBAL template to:

Code

   {$SET,left_width,{$?,{$OR,{$IS_GUEST},{$IS_EMPTY,{$GET,panel_left}}},0,14.3em}}
   {$SET,right_width,{$?,{$GET,helper_panel},425px,{$?,{$OR,{$IS_GUEST},{$IS_EMPTY,{$GET,panel_right}}},0,14.3em}}}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: