PDA

View Full Version : Style Fetching


Kybyrian
04-23-2012, 03:09 AM
To outline my problem, I'm using a php file for my user group colors forum-wide. With multiple styles, I need multiple usergroup colors for each style. This is all in a php file, which looks like this:

<?
include('global.php');
//include('/includes/class_core.php');
header("Content-type: text/css");


switch($vbulletin->userinfo[styleid])
{
case 27:
?>
.ugc_blah{ color:#F57676; }
<?
break;
case 28:
?>
.ugc_blah{ color: #EE3B3B; }
<?
break;
case 16:
default:
//Default Theme
?>
.ugc_blah{ color:#c91c1c; }
<?


break;
}
?>

My problem here seems to be switch($vbulletin->userinfo[styleid]). It works fine when viewing the forum index, but my forum has certain sections that override the user-selected theme. Since I'm using userinfo[styleid], it's grabbing the styleid of the style the user picked, and not the one that the forum is overriding their selection with. This causes the wrong colors to be used on a theme when viewing threads. I'm looking for a way I can grab the styleid of the style the user is currently on, regardless of whether it's an override or not. foruminfo[styleid] was the most clever thing I could think of, and did not work.

kh99
04-23-2012, 07:45 AM
I think userinfo[styleid] should work, but it will only work if your php file is being passed the forumid so it knows if there's an override.

Kybyrian
04-23-2012, 07:35 PM
Well, I don't really know PHP, so I'm not sure of how to go about that, but I also don't see how it would work. userinfo[styleid] should be pulling the styleid the user has chosen in the control panel, which would stay unchanged regardless of override, as the override doesn't actually change the user's control panel settings. It's not necessary to detect the forumid, but rather just pull whatever styleid is currently being used by the page. Is there any variable that defines this?

kh99
04-23-2012, 07:43 PM
OK, I'm confused. I thought the problem is that you wanted the override style but weren't getting it. Are you saying you always want the user selected style no matter which forum you're in?

Also, you say the code above is in a php file - which one?

TheLastSuperman
04-23-2012, 08:24 PM
To outline my problem, I'm using a php file for my user group colors forum-wide. With multiple styles, I need multiple usergroup colors for each style. This is all in a php file, which looks like this:

<?
include('global.php');
//include('/includes/class_core.php');
header("Content-type: text/css");


switch($vbulletin->userinfo[styleid])
{
case 27:
?>
.ugc_blah{ color:#F57676; }
<?
break;
case 28:
?>
.ugc_blah{ color: #EE3B3B; }
<?
break;
case 16:
default:
//Default Theme
?>
.ugc_blah{ color:#c91c1c; }
<?


break;
}
?>

My problem here seems to be switch($vbulletin->userinfo[styleid]). It works fine when viewing the forum index, but my forum has certain sections that override the user-selected theme. Since I'm using userinfo[styleid], it's grabbing the styleid of the style the user picked, and not the one that the forum is overriding their selection with. This causes the wrong colors to be used on a theme when viewing threads. I'm looking for a way I can grab the styleid of the style the user is currently on, regardless of whether it's an override or not. foruminfo[styleid] was the most clever thing I could think of, and did not work.

Ohh my that's too much trouble to do what you want to do...

Try a new plugin:

Product: vBulletin
Hook Location: parse_templates
Title: Custom CSS for our different styles (something you can easily identify etc)
Execution Order: 5
Plugin PHP Code:
if (STYLEID == 27) {
$switchcss = '<style type="text/css">
.ugc_blah{ color:#F57676 !important; }
</style>';
}

if (STYLEID == 28) {
$switchcss = '<style type="text/css">
.ugc_blah{ color: #EE3B3B !important; }
</style>';
}

if (STYLEID == 16) {
$switchcss = '<style type="text/css">
// Default Style
.ugc_blah{ color:#c91c1c !important; }
</style>';
}

$template_hook[headinclude_bottom_css] .= $switchcss;


I would simply customize the default style w/ the value your using for styleid 16 and take that last part out though if it were me. Your also free to use else in there to make it shorter etc but that should do the same thing your having so much trouble with the way your doing it currently ;).

TheLastSuperman
04-23-2012, 08:29 PM
* Where plugins similar to the above really come in handy are the times your heavily customizing a style and some of the different parts of vBulletin share the same CSS yet you need to make changes to location or margins/padding more specifically yet via additional.css it moves the css on all pages not just the page in question. This way via plugin you can use conditionals in it as well, here's a semi-complex yet rough example:

if (STYLEID == 70) {
if (THIS_SCRIPT != 'index') {
$switchbackground = '<style type="text/css">
#footer, .footer {
background:#FFFFFF url(images/main_content_BG_footerWhite.png) right top repeat-y !important;
border:none !important;
margin-top:0px !important;
margin-left:-10px !important;
/*margin-right:-10px !important;*/
-moz-box-shadow:none !important;
-webkit-box-shadow:none !important;
box-shadow:none !important;
}
.mainContent_containerBottom {
width:1020px;
height:10px;
margin-left:auto;
margin-right:auto;
/*text-align:center;*/
background-image: url(images/mainContent_BGbottomWhite.png);
background-repeat: no-repeat;
background-position: bottom center;
}
.forumlastpost.td {
margin-left:155px;
}
.threadstats.td.alt {
padding-left:10px;
}
.threadlastpost.td {
margin-left:-10px;
}
</style>';
} else {
$switchbackground = '<style type="text/css">
#footer, .footer {
background:#FFFFFF url(images/main_content_BG_footer.png) right top repeat-y !important;
border:none !important;
margin-top:0px !important;
margin-left:-10px !important;
/*margin-right:-10px !important;*/
-moz-box-shadow:none !important;
-webkit-box-shadow:none !important;
box-shadow:none !important;
}
.mainContent_containerBottom {
width:1020px;
height:10px;
margin-left:auto;
margin-right:auto;
/*text-align:center;*/
background-image: url(images/mainContent_BGbottom.png);
background-repeat: no-repeat;
background-position: bottom center;
}
.forumlastpost.td {
margin-left:60px;
}
</style>';
}
$template_hook[headinclude_bottom_css] .= $switchbackground;
}

The main css I needed to be different above was of course the forumlastpost td as shown here is the snippet IF you are on the script named index:

.forumlastpost.td {
margin-left:60px;
}

Kybyrian
04-23-2012, 10:54 PM
Thanks for the help TheLastSuperman :) I decided to eliminate my PHP file and go with the plugin, and it works like a charm. Solved the problem I was having and is much cleaner. The thought actually crossed my mind before, but I didn't quite process it.

TheLastSuperman
04-23-2012, 11:10 PM
Thanks for the help TheLastSuperman :) I decided to eliminate my PHP file and go with the plugin, and it works like a charm. Solved the problem I was having and is much cleaner. The thought actually crossed my mind before, but I didn't quite process it.

Ahh I pale in comparison to kh99 in regards to helpful activity in this forum he's the best Advisor I've ever seen on this forum if I speak honestly but that's my opinion (but check his post count and the last few replies in this forum He's a Beast I tell ya! A Beast!). I chimed in because I do a lot of styles and this helps me sort those pesky issues that were giving you a headache and remember you can do many things with plugins with this being just one example so look around and you'll see more in certain threads or examples in the articles forum area now since you have the gist of things already you'll start to see more of the possibilities with vBulletin if it's not up to par for you out of the box ;).

kh99
04-23-2012, 11:48 PM
I need you guys keeping me honest. I was so focused on the styleid that I missed what was going on, but you nailed it.

TheLastSuperman
04-24-2012, 01:44 AM
I need you guys keeping me honest. I was so focused on the styleid that I missed what was going on, but you nailed it.

You already are imo! Also guess what? The only reason I knew about the STYLEID == is because I was using the other not so good versions of it in plugins like GLOBAL style id etc until that one thread where you, Sir Adrian, and others had a long chat about it remember? If not for that thread my idea to start using this all over when a CSS issue came up may have never occurred to me ;).