Public page on a limited site

Melih
Melih
@melih
7 years ago
198 posts
Hello guys, i need help about something.
My site's privacy is set to Limited. I want to create a page to allow public view. Something like "about" page. But i don't know how to do it. I saw some codes in jrMailer module but i didn't get it. (as you all know that i have very little coding skill)

I made that page in php and gave a link on header for not logged in visitors. But i want it to be a part of jamroom. Could you give me a sample or a hint?
updated by @melih: 05/07/17 05:59:21AM
michael
@michael
7 years ago
7,746 posts
If there are more than just the front and login pages that you want visible, I think I'd do it a different way.

I'd make the site PUBLIC but then redirect non-logged-in users away from the defined allowed pages.

Its a bit of code added to the header.tpl template. Its in the bottom part of this doc:

Docs: "HowTo: Make the site visible to Members Only : HowTo: Make the site visible to Members Only"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-admin-handbook/4357/howto-make-the-site-visible-to-members-only#setup-the-redirect-to-send-all-non-logged-in-users-to-the-welcome-page

This code:
{$allowed = array('/welcome', '/user/login', '/user/signup', '/user/forgot')}

{if !jrUser_is_logged_in() && !in_array($_post._uri, $allowed)}
   {jrCore_location("{$jamroom_url}/welcome")}
{/if}

That code reads "If the current url is not yoursite.com/welcome yoursite.com/user/login yoursite.com/user/signup ...... then redirect to yoursite.com/welcome."
Melih
Melih
@melih
7 years ago
198 posts
Thanks Michael, i will consider this way. But I just wanted to make visible only one page so i thought maybe there is a way with site_privacy_check_listener because i don't want all urls except in that array redirect to this page. Simple typo in url will redirect you, in my case, to about page or any other page.
updated by @melih: 02/01/17 03:15:11PM
michael
@michael
7 years ago
7,746 posts
Just to be clear you understand the suggestion: The redirect would only happen for users who are not logged in.

any user not logged in would be limited to viewing only the URL's in your $allowed list and when they try to access a url not on that list, they will be redirected somewhere of your choosing.

Seams like what you're after.

Yes there is a way to do the same thing with a module and a listener, if you prefer that I can figure out the code if necessary.
Melih
Melih
@melih
7 years ago
198 posts
Yes I understand that clearly. And you are right it's a easy and flexable way.

If the other way is not possible i will use this way or my old way (using and external php file).

And ther are other pages allowed to view in jrUser like unsubscribe, activate, new_password... If there will be any changes about this in jrUser, i think, this way can cause problems
michael
@michael
7 years ago
7,746 posts
The next option is to do it with a module. Then you can allow anything through.

Looks like you already know this, but will outline anyhow.

If you create a simple module it will have its unique module url, say 'info' ( call the module xxInfo )

Its url on your site will be
yoursite.com/info

which will display whatever is in the file found at:
/modules/xxInfo/templates/index.tpl

Use the index.php file in your module to create a 'view' at whatever page you want to display
yoursite.com/info/about

would correspond to this function in your modules index.php

function view_xxInfo_about($_post, $_user, $_conf)
{ $_rep = array(); return jrCore_parse_template('about.tpl', $_rep, 'xxInfo'); }

That function reads "When the url yoursite.com/info/about is accessed, go and find the template that exists at /modules/xxInfo/templates/about.tpl and display it."

So that takes care of getting the page displaying, put whatever you want in about.tpl. Its still not displaying for logged out users yet on limited privacy.

To get that working we need to register a listener in our include.php files _init() funciton. That looks like this:


function xxInfo_init(){

   jrCore_register_event_listener('jrUser', 'site_privacy_check', 'xxInfo_site_privacy_check_listener');

    return true;
}


function xxInfo_site_privacy_check_listener($_data, $_user, $_conf, $_args, $event)
{ switch ($_args['option']) { case 'about': $_data['allow_private_site_view'] = true; break; } return $_data; }

Is that enough to get you going?
Melih
Melih
@melih
7 years ago
198 posts
Thank you very much Michael! But i tried the same thing exactly before i wrote here. It doesn't work. It's showing the index page of the site (the opening page, like you write url to go to site first time, before loging in) Page not redirect to sing in page or another page.
Melih
Melih
@melih
7 years ago
198 posts
I think it's about Require Login option in global setting of Genosis Core. If i disabe it i can view the about page. But that option necessary for me. I don't allow anyone can see the page without log in.
updated by @melih: 02/03/17 12:23:13PM
michael
@michael
7 years ago
7,746 posts
What is the URL you're trying on. That should work.

It wont work for non module urls like yoursite.com/about but it should work for module urls like yoursite.com/info/about

Will build it here.
Melih
Melih
@melih
7 years ago
198 posts
site.com/info/about

I did exactly what you said. When i go to "site.com/info/about" it shows exactly the same page when i go to "site.com"

If i disable Require Login option page is showing.
michael
@michael
7 years ago
7,746 posts
working for me. (module attached.)
zip
xxInfo.zip  •  2KB

Melih
Melih
@melih
7 years ago
198 posts
Same thing happening with your module too. Did you try with Genosis Skin with Require Login option checked?
michael
@michael
7 years ago
7,746 posts
not on the genosis skin, I tried on elastic.

The module is active right?
Melih
Melih
@melih
7 years ago
198 posts
Yes it's active and if i uncheck the Require Login option of jrGenCore i can see the about page without login in. But with that option i cannot see the page
Melih
Melih
@melih
7 years ago
198 posts
Yes you can see ss'
1.PNG.png
1.PNG.png  •  14KB

2.PNG.png
2.PNG.png  •  15KB

michael
@michael
7 years ago
7,746 posts
so the situation as I see it: You have 2 locations that force login to view the site.

Is it not an acceptable setup to leave the jtGenCore set to off, and use the privacy setting to force login?
Melih
Melih
@melih
7 years ago
198 posts
If i desabe jrGenCore Require Login option not logged in viewer can see the main page wich i don't want
Melih
Melih
@melih
7 years ago
198 posts
First i think is't only about site's privacy setting. I realize it afterwarts it's not only about privacy setting but also with jrGenCore Require Login setting. So maybe @brian can say something about this.
updated by @melih: 02/04/17 09:49:34AM
michael
@michael
7 years ago
7,746 posts
Melih:
If i desabe jrGenCore Require Login option not logged in viewer can see the main page wich i don't want
First thought is: add another listener to your xxInfo module to block the main page being seen by logged out users.

jrGenCore Require Login setting is a lot more prolific in the code than the "Limited" privacy setting. Its in a ton of places and doesnt have a listener on it. If it has to stay on "Require Login" then alterations would be required to the module to allow it to show other pages while its on.
Melih
Melih
@melih
7 years ago
198 posts
Thank you for your effort Michael. I really appreciate it.

I will continue to use Require Login and maybe i can find another way to do this in time.

Thanks
michael
@michael
7 years ago
7,746 posts
I'll add it as a tracker so we dont loose the idea:
"Add the ability to allow certain url's to show in Require Login mode"
Melih
Melih
@melih
7 years ago
198 posts
Thank you Michael!

Tags