Advertisement:

Author Topic: Private forum. How to make a page visible to all users, including guests?  (Read 1432 times)

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Hello,

I've been researching the forum but I haven't found the way to do this.

I am creating a forum in which the administrator has to manually activate registered users. Guests cannot see anything, just only the login page.

I would want to put a link on the login page that opens a page with the cookie policy. I want this Cookie policy page to keep the same aspect of the forum. I have made the page made with php (using "template_header ();" and "template_footer ();"), but what I don't know is how to make this page visible for guests.

That is my question: how to make a page that guests could see without logging in and taking into account that the forum is completely private?

The way of making the page is not important to me. I mean that if I have to do it differently, without using php, I would do it, no problem. What I would like to know is some clue on how to make that page visible to all users, including guests.

Any help on this would be more than welcome. Thanks in advance.

I am using SMF 2.0.17 and the theme is Dash (from SMFTricks).

Cheers!

Offline m4z

  • 98.8% chimp
  • Localizer
  • Sophist Member
  • *
  • Posts: 1,089
  • /mɛs/
SSI is your friend. Maybe this badly searchable FAQ entry specifically.
"Faith is what you have in things that don't exist."
--Homer Simpson

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
You can also stick it in function template_kick_guest() in Login.template.php.

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Hello,

SSI is your friend. Maybe this badly searchable FAQ entry specifically.

Thank you for your answer m4z.

Yes, I had already used SSI.php and the page looked good, it looked the same as the forum. The problem is that you have to login to see it, guests cannot see it.

When researching, I found in this forum how to make a page using SSI.php. I created a php file called cookies.php with this code inside:
Code: [Select]
<?php require("/home/.../SSI.php");
template_header(); 

   echo 
   
'Here goes the Cookie Policy';

template_footer(); ?>

I have the "Allow guests to browse the forum" option disabled (is a private forum). For that reason the guests cannot see anything. I don't know if having that option disabled, I can solve the problem using SSI ...

I don't want guests to see the forum but I do want them to see the cookie policy. That is what I would want, create a page that guests could see.


You can also stick it in function template_kick_guest() in Login.template.php.


Thank you very much Sir Osis of Liver. I will look into that.


Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,474
you need to wrap your code in

Code: [Select]
if ($context['user']['is_guest'])
 {
   echo '
<h5>Access Denied</h5>
   We are sorry guest, it seems you dont have permission to view these downloads.';
 }

put your code after the echo '

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Thanks Illori. Is the following code correct? (I have tested but unfortunately it loads the login page).

Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
if (
$context['user']['is_guest'])
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>

If I login, the content (the word "COOKIES") does not appear So it works. Because the content is not displayed for non-guests.

The problem is that the guests cannot see the cookie page, they are redirected to the login page (maybe because I have disabled the option "Allow guests to browse the forum").

Also, what I am trying to do is that everyone can see the page, guests and non-guests.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,474
Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
global 
$context;
if (
$context['user']['is_guest'])
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>



try that and see if it works. I cannot test it currently. if it works for guests then it can be modified for logged in users.

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Thanks Illori. But does not work. It redirects the guests to the login page.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,474
try this one.

Code: [Select]
<?php require("/home/.../SSI.php");

template_header(); 
global 
$modSettings;
if (
$modSettings['allow_guestAccess']=1)
 {
   echo 
   
'COOKIES';
}
template_footer(); ?>

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Same result. Redirects to login page.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #10 on: January 21, 2020, 05:26:33 PM »
If the cookie policy isn't too wordy, you can just add it to the text header in the login window -

Login.template.php

Code: [Select]

// Show the message or default message.
echo '
<p class="information centertext">
', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />
', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '
</p>';


Login.english.php

Code: [Select]

$txt['warning'] = 'Warning!';
$txt['only_members_can_access'] = 'Only registered members are allowed to access this section.';
$txt['login_below'] = 'Please login below or';
$txt['register_an_account'] = 'register an account';
$txt['login_with_forum'] = 'with %1$s.';


Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #11 on: January 21, 2020, 05:30:23 PM »
That would be an option, but the cookie policy text is really long. Thanks anyway.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #12 on: January 21, 2020, 05:57:27 PM »
Do you want to display the login window on same page as cookie policy?

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #13 on: January 21, 2020, 06:07:55 PM »
Do you want to display the login window on same page as cookie policy?


No, I want to display a link to the Cookie policy in the same page as login page. Under the login box.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #14 on: January 21, 2020, 06:57:36 PM »
Interestingly (or not), anything you put under require("YOUR_PATH_TO_SSI.php"); loads guest login, including wiki examples for SSI, if guest browsing is disabled.  Only works if guests can browse forum.

Offline Illori

  • Project Manager
  • SMF Legend
  • *
  • Posts: 52,474
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #15 on: January 21, 2020, 07:25:11 PM »
the code i posted above worked for me in the forum with guests disabled. i did not test it directly with SSI though but it should work the same way.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #16 on: January 22, 2020, 12:17:18 AM »
The SSI call seems to be the problem, it can't get anywhere but guest login regardless of what else is in the file.  Am linking directly to test file, maybe it doesn't work that way,

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #17 on: January 22, 2020, 07:56:14 AM »
the code i posted above worked for me in the forum with guests disabled. i did not test it directly with SSI though but it should work the same way.

The SSI call seems to be the problem, it can't get anywhere but guest login regardless of what else is in the file.  Am linking directly to test file, maybe it doesn't work that way,

Thank you both for your answers.

I can't make it work using SSI.php...  Because it always takes me to the login page. :-\

The only option I see is to make a php file that shows the Cookie policy text but without the appearance or design of the forum, which is not what I want because it is very rare to show a blank page with the Cookie policy text without de theme layout and design.

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,236
  • Hoarding Budweiser in NY
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #18 on: January 22, 2020, 10:57:08 AM »
There are a couple of other options.  You can use a popup window to display the cookie policy over the login page, just have to match background, or you can add the cookie policy to Login.template.php so it's displayed on login page, just a matter of formatting it so it looks ok. 

You may also be able create a clickable or hoverable dropdown -

https://www.w3schools.com/howto/howto_js_dropdown.asp
https://www.w3schools.com/howto/howto_css_dropdown.asp
« Last Edit: January 22, 2020, 11:38:51 AM by Sir Osis of Liver »

Offline Juanchoartes

  • Semi-Newbie
  • *
  • Posts: 28
Re: Private forum. How to make a page visible to all users, including guests?
« Reply #19 on: January 22, 2020, 12:13:33 PM »
Thank you Sir Osis of Liver. I will look into the popup window option. It is not what I wanted but maybe I could get something decent.

I discard the dropdown option because it is a very long text and it would not look good. Thanks anyway for the option.