Private forum. How to make a page visible to all users, including guests?

Started by Juanchoartes, January 20, 2020, 12:34:20 PM

Previous topic - Next topic

Juanchoartes

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!

m4z

"Faith is what you have in things that don't exist."
--Homer Simpson

Es gibt hier im Forum ein deutsches Support-Board!

Sir Osis of Liver

You can also stick it in function template_kick_guest() in Login.template.php.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

Hello,

Quote from: m4z on January 20, 2020, 04:06:35 PM
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:
<?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.


Quote from: Sir Osis of Liver on January 20, 2020, 09:01:40 PM
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.


Illori

you need to wrap your code in

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 '

Juanchoartes

Thanks Illori. Is the following code correct? (I have tested but unfortunately it loads the login page).

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

Illori


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

Juanchoartes

Thanks Illori. But does not work. It redirects the guests to the login page.

Illori

try this one.

<?php require("/home/.../SSI.php");

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


Sir Osis of Liver

If the cookie policy isn't too wordy, you can just add it to the text header in the login window -

Login.template.php



// 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



$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.';


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

That would be an option, but the cookie policy text is really long. Thanks anyway.

Sir Osis of Liver

Do you want to display the login window on same page as cookie policy?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

Quote from: Sir Osis of Liver on January 21, 2020, 05:57:27 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.

Sir Osis of Liver

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.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Illori

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.

Sir Osis of Liver

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,
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

Quote from: Illori 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.

Quote from: Sir Osis of Liver 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,

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.

Sir Osis of Liver

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
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Juanchoartes

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.

Advertisement: