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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 629
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 411
  • Total: 411

Conditional Block (probably the most useful block in the universe)

Started by akulion, February 01, 2007, 03:10:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


IchBin

If you have some way to verify in your URL or something which page you are on for sure. For instance, if you're in your profile, in a topic, or an a certain article page you can always use PHP to detect that by grabbing the information in the $_GET array.

if (isset($_GET['page']) && $_GET['page'] == 3)
echo 'your code goes here';

This will display your code "if you're in article number 3".

wilsy

Quote from: IchBinâ,,¢ on December 27, 2007, 04:12:31 PM
If you have some way to verify in your URL or something which page you are on for sure. For instance, if you're in your profile, in a topic, or an a certain article page you can always use PHP to detect that by grabbing the information in the $_GET array.

if (isset($_GET['page']) && $_GET['page'] == 3)
echo 'your code goes here';

This will display your code "if you're in article number 3".

Hi Ichbin,

Thanks for your help, you certainly get around here and I for one am very grateful.

Thanks!

Wilsy.

MPDesignZ

Hi, I'm a little confused here. I need for my guests to not see any articles except the opening page as well, but I'm lost on to what we are doing here in this thread. Do I need to put all my content that I want hidden from guests in the php block file with the codes provided at the beginning of the thread? Or do I need to do it some other way? And I have no idea what number the guest group is in my forum. I have the default install of 1.1.4 and I have not changed guest members groups or anything of that nature.

Thanks

IchBin

The options you're seeking are not built into TP yet. So to get something to view only for a guest, and not allow guests to view other content will require you to use some custom code. Until then, you'll have to wait until TP 1.0 comes out. Guests do not have an id, because they are not registered. So you use something to check if they are a guest, or if they are logged in.

if ($context['user']['is_logged']){
    echo 'all the stuff for logged in users in between these single quotes';
}

// the above code checks to see if they are logged. If they are not logged, they are a guest and
// it will not show something unless you add and else statement.

else {
    echo 'all the stuff for guests here';
}


Tam

Quote from: IchBinâ,,¢ on January 01, 2008, 05:38:03 AM
if ($context['user']['is_logged']){
    echo 'all the stuff for logged in users in between these single quotes';
}

// the above code checks to see if they are logged. If they are not logged, they are a guest and
// it will not show something unless you add and else statement.

else {
    echo 'all the stuff for guests here';
}


I think this will work for what I am trying to do, but I have a few questions. What I am trying to do is create an article. Within the article I need to place a link that only logged in members can click-on or see. Does the above code have to go in a block or can in go in the article source?

If I have to put it in a block, can I make the block show up only with this particular article?

EDIT - Nevermind, I figured it out. TY

MatthewSchenker

Good Afternoon,
Just wanted to say, I learned more about coding reading this discussion than I did in several lessons!  Thanks for posting it.  I'm going to try toe Conditional Block soon!
Matt

This website is proudly hosted on Crocweb Cloud Website Hosting.