TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,021
  • Total Topics: 21,332
  • Online today: 744
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 244
  • Total: 245
  • lurkalot

Guests only center block

Started by shadrach, December 11, 2006, 06:02:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

shadrach

I want to make a block that appears only for non-registered people, not even for the admins. Is this possible to do? And I'd like it to even be there when they go into the forums section.

Thurnok

#1
Yes, it is possible.

  • Make it a phpblock
  • Select Do not use title/frame in block options
  • Select Do not allow block to collapse in block options
  • Select it to display for Guests only (membergroups that can see this block)
  • Make sure you use echo statements for items you want displayed since the block is a php block
  • Select NO to Hide center panel when in forum from TinyPortal Settings in ACP
  • Use the following framework code inside your block

// needed global var
global $context;
// only display stuff if is a guest user (this will prevent Admin's from seeing as well)
if ($context['user']['is_guest']){
  // put all your display code here... some examples follow (replace examples with your own stuff)
  echo 'This text will be displayed to guests only!<br />';
  echo 'You can put any HTML in here as well, just do not use<br />';
  echo 'Any single quotes within the echo statements, or if you<br />';
  echo 'need to, make sure you escape them using the backslash<br />';
  echo 'Example, I can\'t see why the sky is blue!<br />';
}
Thurnok
The one, the only!

whatever

Simply, make a center block (bbc/html, php or whatever you want to use) and set it for guests only. To make it appear on every page, do nothing: it appears everywhere as default.

G6Cad

Quote from: whatever on December 11, 2006, 01:45:05 PM
Simply, make a center block (bbc/html, php or whatever you want to use) and set it for guests only. To make it appear on every page, do nothing: it appears everywhere as default.

You missing the request he wanted, NOT show for any one exept NON registerd, Admins included.
Your way Admins will see the block/article at all times

stormlrd

true but that should be a small sacrifice without major recoding which is what it would require elsewise.

Thurnok

Shouldn't require major recoding.  If he uses my example, he should be fine.  If it is HTML, simply do a search for single quotes and escape them, then plug the result into an echo ''; statement.
Thurnok
The one, the only!

shadrach

#6
Its a block specifically to annoy people to the point where they just register rather than have to see it.
Oh, and thanks Thurnok :)

Edit: I get this error when I use that code:
Parse error: syntax error, unexpected '>' in /home/fullarmo/public_html/Sources/Load.php(1733) : eval()'d code(35) : eval()'d code on line 12
This is exactly what I have:
// needed global var
global $context;
// only display stuff if is a guest user (this will prevent Admin's from seeing as well)
if ($context['user']['is_guest']){
  // put all your display code here... some examples follow (replace examples with your own stuff)
  echo 'Welcome to Distorted Logic, your number one spot for GFX.<br />';
  echo 'If you are seeing this message, then you are currently viewing the site as a guest which only gives you limited access to many of the sites great features. By joining, you will recieve the following benefits;<br />';
  echo '<br />';
  echo '# This annoying message will be gone ;)<br />';
  echo '# You will be given the ability to post, create threads, show off your art work, PM or chat with other other users and respond to polls. <br />';
  echo '# Access to great tutorials.<br />';
  echo '<br />';
  echo "Registration is very easy, quick, and everything is free. Sign up today!<br />';
}

Thurnok

[shameless plug]
ah... well, you should try my Guest Page View Limit block.  ;)
[/shameless plug]
Thurnok
The one, the only!

Thurnok

Your last echo line you used a double quote to start it, and a single quote to end it:
Quote from: shadrach on December 11, 2006, 11:17:13 PM
  echo "Registration is very easy, quick, and everything is free. Sign up today!<br />';


Change it to:

  echo 'Registration is very easy, quick, and everything is free. Sign up today!<br />';

Thurnok
The one, the only!

shadrach


This website is proudly hosted on Crocweb Cloud Website Hosting.