How to code up a disclaimer page users must pass through to reach certain board?

Started by ElectricSquid, May 20, 2008, 01:03:07 PM

Previous topic - Next topic

ElectricSquid

Hi, I am looking for any help, tips, tricks, or links that will aid me in creating a disclaimer page that users (members and guests) must pass through and agree to before entering the pages of a certian board on my SMF/TinyPortal site. Basically, a redirect with the disclaimer and two choices, I agree (that will let you in, and I disagree (which will dump you back to the main forum page.

I tried to do some searches on the SMF site, and google, but I'm not even sure what to call such a page. At the very least, if someone could tell me what this kind of tweek is called, that would aid in searching.

I control the server, so problems with a host allowing such things are not a problem.

SMF 1.1.5
TinyPortal 0.9.83
PHP 5.2.5
MySQL 4.1
IIS6
Windows Server 2003

Eliana Tamerin

So the question is, what kinds of pages are you looking to have this disclaimer for (topics, boards, articles?) and are the disclaimers all the same or are they individually made?
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

#2
Preferablly, one single disclaimer page for one entire board on the forum that is specially dedicated to anything and everything we would need a disclaimer for.

I would like to make it where even if they (users) travel into that board through a direct link, they are redirected to the disclaimer and pretty much forced to click "I Agree" before they continute to their destination on that board.



Eliana Tamerin

That's not too hard. It'll just take an editing of the BoardIndex.template.php, found in the /Themes/(theme name) folder. If your theme doesn't have one, then edit the default one (/Themes/default).

Oh, and this is assuming that the board is neither a child board, nor has child boards which need to be disclaimered as well.

Replace this:

echo '</a>
</td>
<td class="windowbg2">
<b><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a></b><br />
', $board['description'];


With this:

if ($board['id'] == x)
          echo '</a>
          </td>
          <td class="windowbg2">
            <b><a href="disclaimer.php" name="b', $board['id'], '">', $board['name'], '</a></b><br />
              ', $board['description'];
else
          echo '</a>
          </td>
          <td class="windowbg2">
            <b><a href="', $board['href'], '" name="b', $board['id'], '">', $board['name'], '</a></b><br />
              ', $board['description'];


And for $board['id'] == x, put in the board ID of the board you want. Then for disclaimer.php, put in the link to your disclaimer.

On the disclaimer page, just link to the yourforum.com/index.php?board=x.0 link.

If you want this to work in the forum jump dropdown, then you'll need to edit MessageIndex.template.php and Display.template.php as well.

In the MessageIndex.template.php, find this:
echo '
<option value="?board=', $board['id'], '.0"', $board['is_current'] ? ' selected="selected"' : '', '> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>';


Replace with this:
if ($board['id'] == x)
echo '
<option value="disclaimer.php"', $board['is_current'] ? ' selected="selected"' : '', '> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>';
else
echo '
<option value="?board=', $board['id'], '.0"', $board['is_current'] ? ' selected="selected"' : '', '> ', str_repeat('==', $board['child_level']), '=> ', $board['name'], '</option>';


In Display.template.php, find this:
echo '
<option value="?board=', $board['id'], '.0"', $board['is_current'] ? ' selected="selected"' : '', '> ' . str_repeat('==', $board['child_level']) . '=> ' . $board['name'] . '</option>';


Replace with this:
if ($board['id'] == x)
echo '
<option value="disclaimer.php"', $board['is_current'] ? ' selected="selected"' : '', '> ' . str_repeat('==', $board['child_level']) . '=> ' . $board['name'] . '</option>';
else
echo '
<option value="?board=', $board['id'], '.0"', $board['is_current'] ? ' selected="selected"' : '', '> ' . str_repeat('==', $board['child_level']) . '=> ' . $board['name'] . '</option>';
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

Oh, now that was way too cool!!
Thank you, I'm...     ...speachless :D
I'll try it right away.

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

OK, the main part works, when you click on the board directly, but if you try to go through the Jump To link, I get a "Page Cannot be Found" error.

In the URL that the code put out to the browser, it looks like this;
http://wherethetrailends.com/index.phphttp://wherethetrailends.com/index.php?action=legal/DISCLAIMER

Notice how it has the double URL in there. The second one it the location of the disclaimer page, the first part there is the home page.

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

OK, I tryed that before, but nothing
But it works NOW :D


so how do I catch people with that disclaimer page who have a direct link?
Or is that a whole different monster?


Eliana Tamerin

That's a whole different monster. More than likely, they won't have one. You could also put the disclaimer link in the board's description and reset the options to force everyone to read board descriptions while inside the boards.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Couldn't get the whole context but as I understand; add a checkbox to the disclaimer.php. Then in MessageIndex.php check whether it is checked or not. If not, redirect him back to the disclaimer.php - redirectexit('?action=disclaimer'); -
Former SMF Core Developer | My Mods | SimplePortal

ElectricSquid

I'm using a whole different disclaimer page.
Basically, the user will try to click the board that "needs" a disclaimer.
Instead of going into that board, they are directed to my disclaimer page.
At the bottom of that page, there are two links. One says I DO NOT AGREE, and if they click that, they are escorted out to the main forum page.
And if they click I AGREE, they gain access to the board.

Here is a link to the disclaimer. The I agree button will not bring you to the board, due to you not having over 250 posts yet (the old precaution that hasn't been undone yet)
http://wherethetrailends.com/index.php?action=legal/DISCLAIMER

The disclaimer pretty much explains it all. Some of my members are pretty smart for being backwoods types. We like to tinker with the fun stuff :P

Eliana Tamerin

Could use cookies. But that's beyond my expertise. Or add something to the session, or to the database per user.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Quote from: Eliana Tamerin on May 20, 2008, 11:11:05 PM
Could use cookies. But that's beyond my expertise. Or add something to the session, or to the database per user.

No need for cookies. Just add a checkbox and a button below. Of course between <form> tags. And you can check it with $_POST['checkboxname'].
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

To give an example;

MessageIndex.php

Find:

if (WIRELESS)
$context['sub_template'] = WIRELESS_PROTOCOL . '_messageindex';
else
loadTemplate('MessageIndex');


Add Before:

if($board_info['id'] == '1' && empty($_REQUEST['disclaim'])
redirectexit('?action=disclaim');


Here if the board id is equal to board needs disclaimer and the disclaim agreement is unchecked, it redirects back to the disclaim page without showing anything.

http://127.0.0.1/smf/index.php?board=1.0
Redirected.

http://127.0.0.1/smf/index.php?board=1.0;disclaim=1
To the board.
Former SMF Core Developer | My Mods | SimplePortal

ElectricSquid

#16
I'm happy with how well this disclaimer page mod works on my site. But on the Board Index itself, users can go around the disclaimer easily by clicking the link in the "Last post" section to the right of the board description.

The easy solution could be simply disabling the "Last post" section from showing for these boards.

How do I do that for these boards only?? (board#122 & 123)

Eliana Tamerin

I think something like SiNaN wrote up would work for that circumstance, better than just simply turning it off.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

For some reason I cannot find the code he said to find. So I don't know where to add the code to, or what to do on the other templates, if anything at all.

SMF 1.1.5
TinyPortal 0.9.83
Rhino Theme by Bloc

Eliana Tamerin

Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

I searched that whole template for all sorts of keywords in his "find this" code, but nothing. It's not there and I don't know why. Maybe it's the theme i'm using ???

edit-  but the boards show on my cellphone. I use the cell all the time to reply and stuff.

ElectricSquid

I also checked TPwireless.template and Wireless.template. Nothing.
I searched for "loadTemplate" and "MessageIndex" from the "loadTemplate('MessageIndex');" part of the "find this" code.

Eliana Tamerin

No, in your Sources folder. You're looking in /Themes/default when you should be looking in /Sources for the MessageIndex.php file (it's not a template file).
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!


ElectricSquid

OK, found it, did it, but it did nothing at all.
No errors or anything, just no change. Is there something else I'm supposed to be doing along with his code to make it work?

[SiNaN]

For that we should change the Display.php file. But in that case it will show the disclaimer page for every topic they go in. That can be annoying. Remove the link at the last post, you can just show the last post's subject.
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

Could also just change the last post link on the board index, no?
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ElectricSquid

Removing the link for the latest reply sounds like the easiest and least annoying solution. How do i do that for that board only without losing the link in all our other boards lastest replies?

[SiNaN]

BoardIndex.template.php

Find:

$board['last_post']['link']

Replace:

$board['id'] == '1453' ? $board['last_post']['subject'] : $board['last_post']['link']

Change the 1453 as the board ID. If you want to make it for a couple of boards, you can use in_array function.
Former SMF Core Developer | My Mods | SimplePortal

ElectricSquid

I have board 122 and 123 that needs it. How do i do the in_array for that. Please forgive my newness to this. Im trying to learn as much as i can, as fast as i can, as i go. Thank you for all this great help.

[SiNaN]

If you have two, then you can use this:

($board['id'] == '122' || $board['id'] == '123') ? $board['last_post']['subject'] : $board['last_post']['link']

If you had more, it should have to be:

in_array($board['id'], array(1,2,3,4,5)) ? $board['last_post']['subject'] : $board['last_post']['link']

1,2,3,4,5 are the board IDs.
Former SMF Core Developer | My Mods | SimplePortal

ElectricSquid

Thanks for the lesson and the code. I'll try that once i get home.

ElectricSquid

I tried it and it works perfectly.

Just what I needed to complete the redirect code. Now any user must pass through the Disclaimer Page and Agree before entering these chosen boards.

I have marked this topic as Solved, since the above given code works without error and I have achieved the desired effect by using it.

My thanks to all who helped create this mod


Illori

does not look like it, and i would recommend you upgrade to RC5 so you can get the security fixes. most people are no longer coding for versions of smf that have security issues in them.

Advertisement: