| Author |
Message |
naomi
Beginner


Joined: Dec 16, 2004 Posts: 1
|
Posted: Thu Dec 16, 2004 4:21 am Post subject: Displaying/hiding Blocks |
|
|
Hi there,
I'm fairly new to phpnuke, and am wrestling with it, trying to get it to behave the way I want it to.
My major issue at the moment is with blocks. In a nutshell, I want some pages to display some blocks and not others.
In my research, I have learned the nifty code:
Code: › global $name;
if($name!=Forums)
{
blocks(left);
}
This works well for hiding ALL blocks on the left side in a specific module, eg the Forums.
But what If I wanted to hide just one of the blocks on the left side?
My question is, how does PHPNuke display the blocks, what is the function that calls the blocks?
In mainfile I've found the blocks($side) function. This refers to a whole side however, not a specific block.
In my primitive coding mind, it seems logic that if you can refer to a blocks position in php code, surely you should be able to refer to a blocks' title, or individual ID number.
So we have the $title variable, all blocks have a unique value here. How can I use $title in a similar fashion to how the $name variable is used, and write some php code that does this:
If (viewing forums)
Display (search_block, login_block, forummenu_block)
else
If(viewing indexpage)
Display (mainmenu)
Surely this is possible?
Any help is appreciated, if you'd like me to explain further no problems.
Edit:
After a bit more research I've gotten this far by myself:
Code: › global $name;
if($name!=Content)
{
include("blocks/block-Sample_Block.php");
echo "$content";
}
This works, except it doesnt display the block properly, with its title, colours and size etc, it just displays whatever I have placed in the content variable.
How do I make it display the block properly, whats the function call, cause echoing content isnt enough? |
|
| Back to top |
|
|
AdBot
|
| Post subject: Displaying/hiding Blocks |
|
|
|
|
|
| Back to top |
|
 |
NUOPhil
Beginner


Joined: Dec 17, 2004 Posts: 1
|
Posted: Fri Dec 17, 2004 5:28 pm Post subject: Re: Displaying/hiding Blocks |
|
|
In simple words to do this all you have to do is go to your Admin and go to Modules then find the module you want and go all the way to the right and do what you want. Hope it helps. |
|
| Back to top |
|
|
xperiment
Beginner


Joined: Dec 04, 2003 Posts: 19 Location: Upstate NY
|
Posted: Thu Mar 09, 2006 11:22 am Post subject: Re: Displaying/hiding Blocks |
|
|
That won't do what he wants, that'll load a module in the center block on the main page - he's talking blocks not modules, there is a difference.
There IS a good way to do this, I've done it before and need to again - can someone please refresh my memory?
To refresh the question, I want the Sidebar Block to appear only when the Gallery2 module is loaded, what do I do?
Thanks! |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6287 Location: Washington Township, NJ, USA
|
Posted: Thu Mar 09, 2006 11:34 am Post subject: Re: Displaying/hiding Blocks |
|
|
| check the name of the currently loaded module, if it's your g2 module, don't display the block (this is done in your theme.php file) |
|
| Back to top |
|
|
xperiment
Beginner


Joined: Dec 04, 2003 Posts: 19 Location: Upstate NY
|
Posted: Thu Mar 09, 2006 11:57 am Post subject: Re: Displaying/hiding Blocks |
|
|
i don't get it - I don't understand how this can be done in the theme.php file - if I do what I think you're speaking of, it'll turn OFF all left blocks when I access the module specified.
Last time I had it working well, I added a loop to mainfile.php - I just don't remember exactly what it was. |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6287 Location: Washington Township, NJ, USA
|
Posted: Thu Mar 09, 2006 12:10 pm Post subject: Re: Displaying/hiding Blocks |
|
|
in your theme.php file should be a function called "sideblocks" or something like that. simply check the current $module_name and the block name, if the module name isn't your g2 module, don't display the g2 sidebar.
give me 15 minutes and i'll post a sample. |
|
| Back to top |
|
|
xperiment
Beginner


Joined: Dec 04, 2003 Posts: 19 Location: Upstate NY
|
Posted: Thu Mar 09, 2006 12:16 pm Post subject: Re: Displaying/hiding Blocks |
|
|
| OK thanks dari I'll give it a shot, I've never done anything like this in the theme.php file before |
|
| Back to top |
|
|
dari
Site Admin


Joined: Mar 03, 2003 Posts: 6287 Location: Washington Township, NJ, USA
|
Posted: Thu Mar 09, 2006 12:28 pm Post subject: Re: Displaying/hiding Blocks |
|
|
look for the themesidebox function.
after the function declaration, put:
PHP: › <?php global $module_name; ?>
then, add:
PHP: › <?php if($title == "<g2_sidebar_title>") {
if($module_name !== "gallery2") {
return;
}
} ?> |
|
| Back to top |
|
|
xperiment
Beginner


Joined: Dec 04, 2003 Posts: 19 Location: Upstate NY
|
Posted: Thu Mar 09, 2006 2:03 pm Post subject: Re: Displaying/hiding Blocks |
|
|
You're awesome, works great - and much simpler than the path I was heading down  |
|
| Back to top |
|
|
|
|
|
|
|