Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases

Reply
 
Thread Tools
Details »»

Version: , by Kier Kier is offline
Developer Last Online: May 2011 Show Printable Version Email this Page

Version: 2.0.x Rating:
Released: 02-14-2001 Last Update: Never Installs: 1
 
No support by the author.

UPDATED 28-02-2001



This hack for vB2.0 Beta 2 will allow you to edit a single template set, or all of them at the same time, is dramatically less bandwidth-hungry than the current system, and allows quick searches through the templates by clicking in the <select> element and pressing a key; for example, if you want to find the 'header' template, just click in the select and press 'h' on your keyboard...

To install, follow the following instructions:

First, open the file forums/admin/adminfunctions.php and find the line
Code:
OPTION  {COLOR: #51485F; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 10px}
and replace it with this:
Code:
OPTION    {FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; FONT-SIZE: 10px}
This will allow the text of the <select> elements to be green or red in the templates page...

Next, open the file forums/admin/template.php and find the block of code that looks like this:
PHP Code:
// ###################### Start Modify #######################
if ($action=="modify") {

(
lots of code in here)

}

// ###################### Start search ####################### 
and comment out the code between the { } like this:
PHP Code:
// ###################### Start Modify #######################
if ($action=="modify") {

/*
(lots of code in here)
*/
}

// ###################### Start search ####################### 
Next, just after the first open brace, add a line so that the final code looks like this:
PHP Code:
// ###################### Start Modify #######################
if ($action=="modify") {
include 
"./ktemplate.php";
/*
(lots of code in here)
*/
}

// ###################### Start search ####################### 
Next, find the section of text within the template.php code that looks like this:
PHP Code:
$DB_site->query("INSERT INTO template (templateid,templatesetid,title,template) VALUES (NULL,'$templatesetid','".addslashes("$title")."','".addslashes("$template")."')"); 
and replace it with this:
PHP Code:
$result $DB_site->query("INSERT INTO template (templateid,templatesetid,title,template) VALUES (NULL,'$templatesetid','".addslashes("$title")."','".addslashes("$template")."')");
$templateid $DB_site->insert_id($result); 
Finally, upload the attached file to your forums/admin/ folder, rename it to ktemplate.php and you're all ready to go.

19th Feb 2001 Additions:
The hack will now auto-select the last template you edited when you return to the list from submitting an edit, or adding a new custom template.
Cookie functions can be disabled for users who do not use output_buffering
Lots of minor bug fixes (this one actually works )
Please note: if you do not have output_buffering=On in your php.ini, you should comment out the '$usecookies' line at the top of ktemplate.php
28th Feb 2001 Additions:
I have now restored the original template.php's 'view original' functionality through the use of a little javascript. I have tested the script with browsers going back to Nutscrape 4.6, and they all work fine.
Just as an added extra, the hack now tells you how many global and custom templates you have...
28th Feb 2001 Additions: (more )
I just modified the code a little so that you can double-click in the menus for a default event:
Double-clicking a global template name will activate the 'add' function, giving you the option to create a customized template.
Double-clicking a customized/added template will open the edit page for the selected template.
Right-clicking a customized template will display the original template of that name. (Right-click functionality is IE only.)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 02-19-2001, 05:54 AM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by dwh
Can you explain the meaning of the error, why it happens? Just so we can learn php while we're at it...
Sure.

The script stores the $templatesetid of the template set you are working on in a cookie called $bbadmin_templatesetid.

Cookies are set through the PHP function setcookie(..), which sets the cookie by sending an HTTP header to your browser (like any other cookie-setting mechanism).

Here comes the problem: HTTP headers have to be sent to the browser before any display output has been sent to the browser. My cookie-setting system doesn't abide by that rule at the moment, as I tried to make as few modifications to the original template.php as possible, in order to make installation as easy as possible for all you guys and galls.

Therefore, when you run the script, the setcookie(..) function is actually called after PHP has output stuff to the browser, causing it to fail...

u n l e s s . . .

you have output_buffering enabled in your php.ini file. This has the effect of preventing any output being sent to the browser until the PHP script has completely finished its execution. Therefore, the setcookie function is still valid, even though it's being called at an illegal point in the script. Using vB2's GZip compression system will have the same effect.

If you do not use output_buffering or gzip compression, or if you are using PHP3, then you should comment out the line in ktemplate.php that says $usecookies = "yes";. This will prevent the setcookie(..) function from being called.

Does that make sense to you?
Reply With Quote
  #23  
Old 02-19-2001, 06:01 AM
Guest
 
Posts: n/a
Default

Yes, thank you so much!

But I thot I set my gzip stuff to on in the options? Gotta double check that but I'm pretty sure...
Reply With Quote
  #24  
Old 02-19-2001, 06:17 AM
Guest
 
Posts: n/a
Default

Quote:
Originally posted by dwh
I thot I set my gzip stuff to on in the options? Gotta double check that but I'm pretty sure...
To be honest, I haven't looked that closely at vBulletin's implementation of gzip compression... most implementations employ some form of output buffering, which would allow the cookie to be set, but if the control panel doesn't use the compression, or if vB's gzipping doesn't buffer the output, then setting output_buffering = On in php.ini is going to be the only way to allow the cookie to be set.

Once vB2 goes gold, I will revisit the hack and recode it so that the cookie can be set on any system.
Reply With Quote
  #25  
Old 02-19-2001, 01:41 PM
Guest
 
Posts: n/a
Default

You DO have to set output_buffering on in the php.ini. I tried just setting the vB gzip and the error was still apparent.

Works great with output buffering on though.
Reply With Quote
  #26  
Old 02-22-2001, 04:33 PM
Guest
 
Posts: n/a
Default

I installed this have into v2.0 and it works fine except for one error that appears at the top of each page. It is as follows:

Oops, php3_SetCookie called after header has been sent in ../ktemplate.php on line 46

What does this mean? How can I fix it?
I do have GZip enabled with a level of "1" compression.
Reply With Quote
  #27  
Old 02-28-2001, 03:02 AM
Guest
 
Posts: n/a
Default

very nice hack Keir, however I am missing two options from the original -

1) revert back to original
2) view original

The second in particualr was very helpful, when I screwed up something - or thought I did - and wanted to compare my edited template to the original.
Reply With Quote
  #28  
Old 02-28-2001, 03:16 AM
Guest
 
Posts: n/a
Default

Quote:
1) revert back to original
This functionality is still there, just click the 'remove' button. It does the same thing as the original 'revert to original' hyperlink.
Quote:
2) view original
Yes, this function is currently not available. If any javascript gurus can tell me how to read the yyy part from this: <option value=xxx>yyy</option> then I can put the functionality back in very easily... but I don't know how to pull out that info at the moment. I'm sure it's possible though.
Reply With Quote
  #29  
Old 02-28-2001, 03:25 AM
Guest
 
Posts: n/a
Default

If they click the view default button, run an extra query to get the name of the template known by its templateid and then just grab that template where templatesetid=-1.
Reply With Quote
  #30  
Old 02-28-2001, 03:33 AM
Guest
 
Posts: n/a
Default

Cheers Ed, but I've just found a way to do it without an extra query

Will post an updated hack in a short while once i've integrated it into the existing code
Reply With Quote
  #31  
Old 02-28-2001, 03:58 AM
Guest
 
Posts: n/a
Default

Updated version now available in the first post of the thread.
Reply With Quote
Reply

Thread Tools

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 04:06 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.04290 seconds
  • Memory Usage 2,296KB
  • Queries Executed 25 (?)
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
  • (2)bbcode_code
  • (5)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_onlinestatus
  • (11)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete