Back to General Articles

Merge into $show
by Michael Morris 30 Oct 2004

Hello everyone - here's a quick tip: I'm fond of giving my users a lot of controllable options using user profile fields and then using the phpinclude start template to express those as $show conditionals. I do this because it makes the resultant stylesheets more portable - the user profile field in the $bbuserinfo almost certainly will change from server to server - and if you refer to the same condition multiple times it becomes a pain in the tail to move the style to a new setup.

So I move the $bbuserinfo['fieldX'] stuff over to $show. The reason is that, like $bbuserinfo, $show is declared global in almost every function that deals with data display (the sole exception I know of is the function that parses subforums). You can also choose names for your show variables that are descriptive, which in turn makes your code easier for others to read.

Initialize your custom $show variables in your phpinclude_start template like so...

PHP Code:
$show array_merge($show,
'custom1',
'custom2',
); 
And so on. After you initialize them, you can then assign their values. Changing the $bbuserinfo over into them - that's a lesson for another time (this is supposed to be a "quick tip")

vblts.ru supports vBulletin®, 2022-2024