vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Dynamically alter $stylevar['codeblockwidth'] (https://vborg.vbsupport.ru/showthread.php?t=182970)

Antivirus 06-19-2008 04:33 PM

Dynamically alter $stylevar['codeblockwidth']
 
I have been trying to dynamically alter the width of $stylevar['codeblockwidth'] based upon a condition in php, however it's not behaving as expected. It's just stretching to the max width to fit all the contents within the code tags.

I am inserting the following code into hook group_complete
PHP Code:

$stylevar['codeblockwidth']    = $vbulletin->options['scst_rightgblockwidth']; 

Anyone know why it's not working?

Opserty 06-19-2008 05:29 PM

Have you checked the PHP code around the hook, it might give you clues.

Maybe the variable names are incorrect or something?

Where is the hook located? (I haven't used/come across it before)

Antivirus 06-19-2008 05:36 PM

the hook's located within group.php

I'm thinking it's something to do with bbcode being parsed at adifferent time than template output. Problem is though that template bbcode_code is cached way before any php runs at all, which might be a problem as well...

Boofo 06-19-2008 05:36 PM

You need to add it to global_start. That is where I am doing the same type thing.

Code:

if (is_browser('ie'))
{
 if (THIS_SCRIPT != 'private')
 {
  $stylevar['codeblockwidth'] = "890px";
 }
 else
 {
  $stylevar['codeblockwidth'] = "745px";
 }
}

I have it set to auto in the skin.

Antivirus 06-19-2008 05:48 PM

Boofoo, That would work for me if I just needed to modify it to the same size, all the timje, however since it's being modified based upon a conditional within the $group array, that's too soon...

But seeing your code did help me figure out the problem... the issue was that the template bbcode_code sets the width using $stylevar['codeblockwidth'] as expected, but the 'px' isn't included in the template, it is included in the var... so the following works as expected within hook group_complete

PHP Code:

switch($sc_gblock['position'])
{
    case 
'left':
    {
        
$stylevar['codeblockwidth'] = ($vbulletin->options['scst_leftgblockwidth'] - 60) . 'px';
    }
    break;
    case 
'right':
    {
        
$stylevar['codeblockwidth'] = ($vbulletin->options['scst_rightgblockwidth'] - 60) . 'px';
    }
    break;



Boofo 06-19-2008 05:53 PM

What is the minue 60 for? I set the width to auto as FF handles that fine. It is just IE that gets messed up with auto. I could have dione it with a setting variable but since I am only doing it in one skin, I hard-coded it.

Antivirus 06-19-2008 06:20 PM

I'm using the - 60 to make ensure that the code is less than the width of the cell, which is set using $vbulletin->options['scst_leftgblockwidth']

Boofo 06-19-2008 06:33 PM

So this is part of a larger hack then and not just for the width?


All times are GMT. The time now is 05:09 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01167 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete