Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-23-2012, 03:09 AM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Style Fetching

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:

PHP Code:
<?
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.
Reply With Quote
  #2  
Old 04-23-2012, 07:45 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 04-23-2012, 07:35 PM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #4  
Old 04-23-2012, 07:43 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 04-23-2012, 08:24 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Kybyrian View Post
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:

PHP Code:
<?
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:
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 .
Reply With Quote
2 благодарности(ей) от:
kh99, Kybyrian
  #6  
Old 04-23-2012, 08:29 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

* 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:

PHP Code:
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:

PHP Code:
.forumlastpost.td {
margin-left:60px;

Reply With Quote
  #7  
Old 04-23-2012, 10:54 PM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 04-23-2012, 11:10 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Kybyrian View Post
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 .
Reply With Quote
  #9  
Old 04-23-2012, 11:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 04-24-2012, 01:44 AM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
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 .
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:51 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.11262 seconds
  • Memory Usage 2,282KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (2)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete