Back to vBulletin 4.x Add-ons

Edit StyleVars page
Mod Version: 1.3, by Lynne

vB Version: 4.1.11 Rating: (7 votes - 5.00 average) Installs: 37
Released: 09 Feb 2011 Last Update: 10 Mar 2012 Downloads: 120
Not Supported Code Changes  

This is just a new page for showing the .css template and having all the stylevars clickable and then editable in the bottom screen. This uses iframes, so if you browser doesn't support that, then it won't work and I cannot help you with this.

You will need to open up and edit the admincp/template.php file.

**edited for 4.1.11 below** Basically just add the code in red to the existing code.

Find (under $_REQUEST['do'] = 'add'):
Code:
    print_textarea_row($vbphrase['template'] . '
            <br /><br />
            <span class="smallfont">' .
            iif($vbulletin->GPC['title'], construct_link_code($vbphrase['show_default'], "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=view&amp;title=" . $vbulletin->GPC['title'], 1) . '<br /><br />', '') .
            '<!--' . $vbphrase['wrap_text'] . '<input type="checkbox" unselectable="on" onclick="set_wordwrap(\'ta_template\', this.checked);" accesskey="w" checked="checked" />-->
            </span>',
        'template', $templateinfo['template_un'], 22, '5000" style="width:99%', true, true, 'ltr', 'code');
Change to:
Code:
    $isscss = strpos($vbulletin->GPC['title'],'.css');    
    print_textarea_row($vbphrase['template'] . '
            <br /><br />
            <span class="smallfont">' .
            iif($vbulletin->GPC['title'], construct_link_code($vbphrase['show_default'], "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=view&amp;title=" . $vbulletin->GPC['title'], 1) . '<br /><br />', '') . 
iif($isscss === false AND $vbulletin->GPC['dostyleid'] != -1, '', construct_link_code('Edit StyleVars', "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=editcss&amp;dostyleid=" .
                $vbulletin->GPC['dostyleid'] . "&amp;title=". $vbulletin->GPC['title']."&amp;templateid=" .
                $vbulletin->GPC['templateid'], 1) . '<br /><br />') .
            '<!--' . $vbphrase['wrap_text'] . '<input type="checkbox" unselectable="on" onclick="set_wordwrap(\'ta_template\', this.checked);" accesskey="w" checked="checked" />-->
            </span>',
        'template', $templateinfo['template_un'], 22, '5000" style="width:99%', true, true, 'ltr', 'code');
Then find (under $_REQUEST['do'] = 'edit'):
Code:
    print_textarea_row($vbphrase['template'] . '
            <br /><br />
            <span class="smallfont">' .
            iif($template['styleid'] != -1, construct_link_code($vbphrase['show_default'], "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=view&amp;title=$template[title]", 1) . '<br /><br />', '') .
            '<!--' . $vbphrase['wrap_text'] . '<input type="checkbox" unselectable="on" onclick="set_wordwrap(\'ta_template\', this.checked);" accesskey="w" checked="checked" />-->
            </span>',
        'template', $text, 22, '5000" style="width:99%', true, true, 'ltr', 'code');
Change to:
Code:
    $isscss = strpos($template[title],'.css');    
    print_textarea_row($vbphrase['template'] . '
            <br /><br />
            <span class="smallfont">' .
            iif($template['styleid'] != -1, construct_link_code($vbphrase['show_default'], "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=view&amp;title=$template[title]", 1) . '<br /><br />', '') . 
iif($isscss === false AND $template['styleid'] != -1, '', construct_link_code('Edit StyleVars', "template.php?" . $vbulletin->session->vars['sessionurl'] . "do=editcss&amp;dostyleid=" .
                $template['styleid'] . "&amp;templateid=$template[templateid]", 1) . '<br /><br />') .
            '<!--' . $vbphrase['wrap_text'] . '<input type="checkbox" unselectable="on" onclick="set_wordwrap(\'ta_template\', this.checked);" accesskey="w" checked="checked" />-->
            </span>',
        'template', $text, 22, '5000" style="width:99%', true, true, 'ltr', 'code');
Then find (at the bottom of the page):
PHP Code:
print_cp_footer(); 
Add above:
PHP Code:
// #############################################################################
// add a new page to edit stylevars
if ($_REQUEST['do'] == 'editcss')
{
require_once(
DIR '/includes/adminfunctions_stylevar.php');

    
$vbulletin->input->clean_array_gpc('r', array(
        
'title'        => TYPE_STR,
        
'group'        => TYPE_STR,
        
'searchstring' => TYPE_STR,
        
'expandset'    => TYPE_STR,
    ));

if (
$vbulletin->GPC['dostyleid'] == -1)
    {
        
$style['title'] = $vbphrase['global_templates'];
    }
    else
    {
        
$style $db->query_first("SELECT title FROM " TABLE_PREFIX "style WHERE styleid = " $vbulletin->GPC['dostyleid']);
    }

    if (
$vbulletin->GPC['title'])
    {
        
$templateinfo $db->query_first("
            SELECT * FROM " 
TABLE_PREFIX "template
            WHERE styleid IN (-1,0) AND title = '" 
$db->escape_string($vbulletin->GPC['title']) . "'
        "
);
    }
    else if (
$vbulletin->GPC['templateid'])
    {
        
$templateinfo $db->query_first("SELECT * FROM " TABLE_PREFIX "template WHERE templateid = " $vbulletin->GPC['templateid']);
        
$vbulletin->GPC['title'] = $templateinfo['title'];
    } 
        

$prepend '<style type="text/css">
.edit_scroller {
    width:100%;
    min-height:300px;
    max-height: 350px;
    max-width: 800px;
    overflow: auto;
    border: 1px solid black;
}
</style>'
;
    
    echo 
$prepend;

    
print_table_start();
    
print_table_header('Edit StyleVars');

    
construct_hidden_code('group'$vbulletin->GPC['group']);

    
$products fetch_product_list();

    if (
$vbulletin->GPC['title'])
    {
        
construct_hidden_code('product'$templateinfo['product']);
        
print_label_row($vbphrase['product'], $products["$templateinfo[product]"]);
    }
    else if (
$vbulletin->debug)
    {
        
print_select_row($vbphrase['product'], 'product'$products$templateinfo['product']);
    }
    else
    { 
// use the default as we dictate in inserttemplate, if they dont have debug mode on they can't add templates to -1 anyway
        
construct_hidden_code('product''vbulletin');
    }

    
construct_hidden_code('templateid'$templateinfo['templateid']);
    
construct_hidden_code('expandset'$vbulletin->GPC['expandset']);
    
construct_hidden_code('searchset'$vbulletin->GPC['expandset']);
    
construct_hidden_code('searchstring'$vbulletin->GPC['searchstring']);
    
print_style_chooser_row('dostyleid'$vbulletin->GPC['dostyleid'], $vbphrase['master_style'], $vbphrase['style'], iif($vbulletin->debug == 110));
    
    
$stylevars fetch_stylevars_array();

    
$templateinfo['template_new'] = $templateinfo['template_un'];
    
    
$groups array_keys($stylevars);
    foreach(
$groups AS $group)
    {
        
$stylevarids array_keys($stylevars[$group]);
        foreach (
$stylevarids AS $stylevarid)
        {
            if (
$stylevarid)
            {
                
$find = array('/\{vb:stylevar '.$stylevarid.'\}/','/\{vb:stylevar '.$stylevarid.'(\\.([^}]*))\}/');
                
$replace "<a href=\"stylevar.php?" $vbulletin->session->vars['sessionurl'] . "do=fetchstylevareditor&amp;stylevarid[]=" $stylevarid "&amp;dostyleid=" $vbulletin->GPC['dostyleid'] . "\" target=\"see_stylevar\">{vb:stylevar ".$stylevarid."$1}</a>";
        
                
$templateinfo['template_new'] = preg_replace($find$replace$templateinfo['template_new']);
            }    
        }
    }
    
    
print_input_row(
        
$vbphrase['title'],
        
'title',
        
$vbulletin->GPC['title']);
    
print_label_row($vbphrase['template'],
        
'<div class="alt1 edit_scroller"><pre>' $templateinfo['template_new'] . '</pre></div>');
        
    
print_label_row($vbphrase['stylevar'], '<iframe name="see_stylevar" id="edit_scroller" class="alt2 edit_scroller"></iframe>');

    
print_table_footer();


Now when you go to Style Manager > find Style > Edit Templates and click on a .css template to edit (it will ONLY work in .css templates!), you will have the new option on the left to "Edit StyleVars".



If you click that, you get a new tab with the .css template in the top box (not editable on this page) and it has all the *editable* stylevars clickable (for example, in userprofile.css, they use variables, not stylevars, so you won't have clickable stylevars there). If you click on a stylevar, it will open in the bottom of the window and you may edit.





Tested in Firefox, Safari, Chrome, and Opera on my Mac.

And thank you to ForumsMods for sharing a diff file - &d=1297297462 (for version 1.1, which works, but doesn't have css changes)

1.2 - 2011-02-11 - changed some CSS for the divs and fixed a phrase.
1.3 - 2012-03-10 - added a file with the changes needed for 4.1.11

Download

File Type: %1$s Edit StyleVars1.3.zip (188.5 KB, 44 downloads)

Screenshots

Click image for larger version
Name:	editstylevars1.png
Views:	2355
Size:	30.4 KB
ID:	126555   Click image for larger version
Name:	editstylevars2.png
Views:	2329
Size:	31.2 KB
ID:	126556   Click image for larger version
Name:	editstylevars3.png
Views:	2324
Size:	121.6 KB
ID:	126581  

Similar Mods

Miscellaneous Hacks Design Tool: Show what Stylevars are used on a Page vBulletin 4.x Add-ons

vblts.ru supports vBulletin®, 2022-2024