vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Administrative and Maintenance Tools - Edit StyleVars page (https://vborg.vbsupport.ru/showthread.php?t=258614)

Lynne 02-08-2011 10:00 PM

Edit StyleVars page
 
1 Attachment(s)
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".

https://vborg.vbsupport.ru/attachmen...1&d=1297286569

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.

https://vborg.vbsupport.ru/attachmen...1&d=1297286569

https://vborg.vbsupport.ru/attachmen...1&d=1297354009

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

And thank you to ForumsMods for sharing a diff file - patch.zip (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

ForumsMods 02-09-2011 09:44 PM

Great idea.
Installed and Nominated.

Can you make a diff file?

Lynne 02-09-2011 09:54 PM

Quote:

Originally Posted by ForumsMods (Post 2160732)
Can you make a diff file?

It's basically two quick edits to find/replace and then just add a bunch of stuff at the end. And, besides that, I don't have an application to make diff files.

ForumsMods 02-09-2011 10:25 PM

1 Attachment(s)
Quote:

Originally Posted by Lynne (Post 2160734)
It's basically two quick edits to find/replace and then just add a bunch of stuff at the end. And, besides that, I don't have an application to make diff files.

Yes, but is easier for me to apply using diff files.
Also for next vB releases.

I made a diff file for vBulletin 4.1.1 (40651).

Take a note that with default vB Style does not display correctly. Would be better to use style classes and change 'Phrase' to '$vbphrase['stylevar']'.

mfnforex 02-09-2011 10:30 PM

Thank you

Lynne 02-09-2011 10:58 PM

Quote:

Originally Posted by ForumsMods (Post 2160745)
Yes, but is easier for me to apply using diff files.
Also for next vB releases.

I made a diff file for vBulletin 4.1.1 (40651).

Take a note that with default vB Style does not display correctly. Would be better to use style classes and change 'Phrase' to '$vbphrase['stylevar']'.

thank you. I'll link to this in my first post.

I'm not sure what you mean about the default vB style not displaying correctly. It's showing just fine on my site.

I'm using the default admincp functions to build the page (print_table_start, print_table_header, etc) instead of redoing the whole thing. And yes, I should have used a phrase. I wrote this as a quick project for myself and then decided to share it and I thought I had cleaned it up, but I did forget to look at phrases. I'll catch that if I have another release.

ForumsMods 02-09-2011 11:28 PM

1 Attachment(s)
Quote:

Originally Posted by Lynne (Post 2160750)
thank you. I'll link to this in my first post.

I'm not sure what you mean about the default vB style not displaying correctly. It's showing just fine on my site.

I'm using the default admincp functions to build the page (print_table_start, print_table_header, etc) instead of redoing the whole thing. And yes, I should have used a phrase. I wrote this as a quick project for myself and then decided to share it and I thought I had cleaned it up, but I did forget to look at phrases. I'll catch that if I have another release.

See attachments.
You are using hard-coded background and color.
HTML Code:

<div class="alt2" style="border: 1px solid black; background-color: white; height: 350px; width: 99%; max-width: 800px; overflow: scroll">
I would change alt2 to bginput, delete border and background-color.

Also delete border and background for iframe and add bginput class to it.

TheLastSuperman 02-10-2011 03:53 AM

Quote:

Originally Posted by ForumsMods (Post 2160732)
Great idea.
Installed and Nominated.

AGREED!

benstillman 02-10-2011 05:47 PM

Why the hell wasn't this standard!? This is awesome!

jparks46 02-15-2011 05:22 PM

This is an amazing idea. Thank you so much Lynne! Installed + nominated as soon as I get home!

Rafa-el 03-04-2011 11:09 AM

Very good idea!

BlackThorn 03-04-2011 06:32 PM

Thanks Lynne, that's awesome...

ifitsmedia 03-04-2011 11:33 PM

Thanks for this! Also don't understand why this isn't included as a standard feature.

CRDeveloper 03-06-2011 06:13 AM

Make this an Add-on pleeeeease!!!

Boofo 03-06-2011 06:42 AM

Quote:

Originally Posted by CRDeveloper (Post 2170056)
Make this an Add-on pleeeeease!!!

As you have to manually do file edits, it can NOT be done any other way.

fxwoody 04-27-2011 11:34 AM

That's the best one i seen so far for the new version....at least for some of us who like to play in the styles and codes!

Great share Lynne and friends ;)

Maybe it should be added as a designer series???? I also added the [vb4] Adding a stylevar from carnage and it as all the potential to write anything you want now!

Cheers

FReeSTER 09-17-2011 06:20 PM

let me be stupit for so many times already. lol How do you load the diff file?

I want to try that as I get a blue box but nothing else on the stylevar box below without any options. All I did was edit the template.php file

thanks this is great and much easier then hardcoding

Lynne 09-17-2011 08:52 PM

If you don't know what a diff file is for, then you should just do the edits in the first post.

Make sure you put the last bit of code *before* the line I tell you to look for, not after or you will just get a blank page.

FReeSTER 09-17-2011 11:48 PM

Yes that was how I did it by your directions

I use DreamWeaver to edit my files since it have the option to look and replace. lol

and for the last code i added the code all the way in the bottom above these lines

Quote:

print_cp_footer();

/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded: 21:15, Fri Jun 3rd 2011
|| # CVS: $RCSfile$ - $Revision: 40651 $
|| ################################################## ##################
\*================================================ ======================*/

Lynne 09-18-2011 03:58 AM

I just went and followed the instructions to add this to my default 4.1.6 site and this works just fine on there. I would suggest double-checking what you did by starting over if it is not working correctly.

HMBeaty 09-18-2011 04:06 AM

Very cool! Not sure why I haven't seen this one before :) Installed. Thanks Lynne :D

Andreas 09-18-2011 06:59 AM

Quote:

Originally Posted by Boofo (Post 2170061)
As you have to manually do file edits, it can NOT be done any other way.

It can ;)

I've done this for TMS 1.2.0 which should be ready for production soon.

Boofo 09-18-2011 02:07 PM

Quote:

Originally Posted by Andreas (Post 2247421)
It can ;)

I've done this for TMS 1.2.0 which should be ready for production soon.

TMS does file edits now???

FReeSTER 09-18-2011 04:50 PM

OMGosh, man the more I try the more is the same. lol

Lynned there is my file can you take a look at it please if your time allow you to.
Is just I think I have done everything like the book and I keep getting the same results :o

Andreas 09-18-2011 06:22 PM

[ot]
Quote:

Originally Posted by Boofo (Post 2247520)
TMS does file edits now???

No, FMS (File Modificationm System) does do that :D

What I meant is that TMS 1.2.0 has a function that does allow editing of stylevars from the modify template from without requiring file edits.
[/ot]

Sorry for hijacking you thread Lynne :(

Lynne 09-18-2011 08:48 PM

Quote:

Originally Posted by FReeSTER (Post 2247562)
OMGosh, man the more I try the more is the same. lol

Lynned there is my file can you take a look at it please if your time allow you to.
Is just I think I have done everything like the book and I keep getting the same results :o

Each line of php that ends in a ; must then have a line feed. You have merged the lines together in your file edits such as this line (2215):
PHP Code:

        'template'$templateinfo['template_un'], 22'5000" style="width:99%'truetrue'ltr''code');  print_template_javascript(); 

That needs to be:
PHP Code:

        'template'$templateinfo['template_un'], 22'5000" style="width:99%'truetrue'ltr''code');  
print_template_javascript(); 

You did similarly at least three times.

Successfulsteps 09-19-2011 01:01 AM

Awesome mod, I will tag to install! Thank you!

FReeSTER 09-19-2011 02:49 PM

thank you Lynned, another thing I have learn from PHP. great for you to share me the tip.

well I did just that and and still the same mate.

Lynne 09-19-2011 03:34 PM

Quote:

Originally Posted by FReeSTER (Post 2247893)
thank you Lynned, another thing I have learn from PHP. great for you to share me the tip.

well I did just that and and still the same mate.

Did you only fix that one line? Because I saw several like that.

FReeSTER 09-19-2011 05:12 PM

Quote:

Originally Posted by Lynne (Post 2247911)
Did you only fix that one line? Because I saw several like that.

lol :o :D yes just one that line. lol
I will check on the file correctly and fix it each one of them

FReeSTER 09-19-2011 05:42 PM

Ok reporting back. I double checked all of my edits and I found 4 of them were merged so I fixed but results still the same

Lynne 09-19-2011 08:42 PM

I would suggest starting with a totally new file and redoing the file edits. Only this time, make sure you put the code on their own lines and not merge lines at all.

Hippy 10-10-2011 07:28 PM

I pulled the changes out from the code it self and added it in it's correct line since a couple things changed since then..this worked up till 4.1.6 then 4.1.7 it will no longer work..
the edits where perfect.. did it 2 times to make sure , used compareit..
when you click on the style manager in the admincp you just get a blank screen :(

code used ..
PHP Code:

$isscss strpos($vbulletin->GPC['title'],'.css'); 

PHP Code:

iif($isscss === false AND $vbulletin->GPC['dostyleid'] != -1''construct_link_code('Edit StyleVars'"template.php?" $vbulletin->session->vars['sessionurl'] . "do=editcss&amp;dostyleid=" 

PHP Code:

iif($isscss === false AND $template['styleid'] != -1''construct_link_code('Edit StyleVars'"template.php?" $vbulletin->session->vars['sessionurl'] . "do=editcss&amp;dostyleid=" 

and the large chunk of code above
Code:

print_cp_footer();

any help with this would be great
thanks for sharing this great mod lynne

Lynne 10-10-2011 07:48 PM

I just went through and modified my template.php file for 4.1.7 using the instructions in post 1 and it is working just fine on my site. I am getting no blank screens. I'd suggest you check your error_logs.

Hippy 10-10-2011 08:31 PM

yep I should of though of that ..
this is the error
PHP Parse error: syntax error, unexpected ';' in /public_html/testvb/admincp/template.php on line 2224,
line 2224 is
Code:

'template', $templateinfo['template_un'], 22, '5000" style="width:99%', true, true, 'ltr', 'code');
this is under 3 lines under the first edit..
this line was not even touched

Hippy 10-10-2011 08:35 PM

my bad I see where I went wrong...

Lynne 10-10-2011 09:14 PM

Glad you got it figured out. :)

Hippy 10-10-2011 09:27 PM

thanks you for providing this for everyone..
should be default with vb..

I don't know what I was thinking when I was editing that file..
I been fixing so much broken stuff these past few days.. I need a break to get back on track..

once again
your efforts and support are very much appreciated..

voglermc 10-15-2011 02:30 PM

Sweet!

Hippy 01-08-2012 03:27 PM

1 Attachment(s)
Hi Lynne
this was driving me crazy today

after checking over and over my edits .. I realized this was not a edit issue it was a IE9 issue..
I checked in ff and worked like it should..

whats happening is everytime you mouse over a style var in the template the space between the 2 boxes grow

I attached a couple screen shots so you can see what I mean..

thanks


All times are GMT. The time now is 06:01 AM.

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.01545 seconds
  • Memory Usage 1,912KB
  • 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
  • (6)bbcode_code_printable
  • (1)bbcode_html_printable
  • (7)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete