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,970
  • Latest: bynw
Stats
  • Total Posts: 196,046
  • Total Topics: 21,335
  • Online today: 232
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 207
  • Total: 207

HOWTO :: Hide the Blocks at specific action

Started by Megaforum, November 03, 2007, 09:31:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dragooon

Here is the way if you want to hide the blocks(weather right/left/center or all) when in specific action or for specific membergroup or for specific membergroup when in some action
I wasn't sure weather it has been told before or not, but I desperately wanted it to figured a way out to do so, and just sharing it :)



This is tested and it works with SMF 1.1.x and TP 0.9.8


Where to?
First of all the file to be edited is /Sources/TPortal.php and the place where you have to add the code is before }
function TPfrontpage($type)
{

Make sure of the brackets and curly braces, It should be right before this part, at the very end of the TPortal_init() function.


How to?
Lets say, we have a Arcade and a Gallery and we want to hide all the blocks when we get in them.
Now first of all, find there actions, which can be found by there URL.(I.e. For SMFArcade it can be http://yoururl.com/index.php?action=arcade)
And the action is "arcade"(Without the quotes), so in the same way, you can find for the rest.
So Actions for Arcade and Gallery is "arcade" and "gallery"(Without the quotes).
So as said before in "Where to", find that code and add before
if(in_array($context['current_action'], array('arcade', 'gallery'))) {
        tp_hidebars('all');
         }

Now to understand the parts, Lets start with the "if" which is if(in_array($context['current_action'], array('arcade', 'gallery')))
$context['current_action'] is where the current action is stored, so this is the root. I used in_array so that we can find out weather the action is in $context['current_action'].
Now the ('arcade', 'gallery') are the names of the action. They must be in in single quotes ( ' ) and 2 or more must be separated by using commas
Ex ('something', 'something again', 'and something'). The rest closing brackets are to close so that it will prevent syntax errors and the starting curly brace "{" and the end one "}" in which if it gets true, the code executes inside it.
Lets see, this is true? Lets get the tp_hidebars('all') executed, which you may have guessed right, this hides the stuff.
So well this is basically what we have to do.


Some more Stuff
Even though the previous part was the main but was it enough? No? Lets continue ;)
Now that you know how to do the basics, lets get in deeper.
Here are the 4 attributes of tp_hidebars() function
tp_hidebars('center') - Hides the Center Blocks
tp_hidebars('left') - Hides the Left blocks
tp_hidebars('right') - Hides the right block and
tp_hidebars('all') - Hides all the blocks.
Lets say you want to hide the left blocks for someone in Group 9 when they are in a action named "shop"
if(in_array(9, $user_info['groups']) && in_array($context['current_action'], array('shop'))) {
tp_hidebars('left');
}

Get it? $user_info['groups'] contains its groups and 9 is the group ID, and the rest part you know.
This is how many combinations can be made.
Some well demanded variables are
$context['user']['is_guest'] - Weather the user is guest or not
$context['user']['is_admin'] - Weather the user is admin or not
$context['user']['id'] - Users ID
$context['current_action'] - Current Action as explained.
$user_info['groups'] - Contains the User's Groups
And there are many


Feel free to post any Questions or Comments in this thread


Made by Dragooon and released over at TinyPortal and TinyPortalMedia

MinasC



IchBin

If you want the option to turn on/off in your admin panel you can follow my tutorial I posted.
http://www.tinyportal.net/index.php?topic=13031.msg108852#msg108852

Dragooon


Wurst

Hi...

i want to hide the blocks in the whole forum...

I successfully removed them from the forumindex, but not from the different threads and boards...
If i open for example : www.mysite.com/smf/index.php?board=5.0 , then the blocks are visible again... also if i open www.mysite.com/smf/index.php?topic=5.0  ...

Is it possible that all blocks are visible in the portal and to hide them in the whole forum???

thx
Wurst

IchBin

Admin>TinyPortal>Settings>Panel> On this page each panel left/right/center have the option to show or "Not" when in the forum.


morskisrle

What would be the code for hiding blocks (tp_hidebars()) in topics?
So when i click on a topic and open it, that it don't get any blocks showed?

IchBin

if (isset($_GET['topic'])){
     tp_hidebars();
}

This website is proudly hosted on Crocweb Cloud Website Hosting.