Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Better "Preview" for templates in the CP Details »»
Better "Preview" for templates in the CP
Version: 1.00, by Admin (Coder) Admin is offline
Developer Last Online: Nov 2024 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 05-21-2002 Last Update: Never Installs: 25
 
No support by the author.

This is a very quick hack that enhaces the "Preview" feature in the Template Editor. Currently I find the preview to be useless, I can also see funky colors and odd tables.
With this hack, you will get a slightly better idea of how the template will really look like, because all the {replacement} variables will be replaced with their real value.

If you have Mutt's "Advanced Template Editor" hack installed, please follow the directions in this post:
https://vborg.vbsupport.ru/showthrea...&postid=253878
Thanks Mutt!


In template.php replace:
PHP Code:
function dotemplatejavascript() {

    
$buttonextra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
win = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes'); 
With this:
PHP Code:
function dotemplatejavascript() {
    global 
$DB_site$bburl;

    
$replacementsetid 1;    ### Change me to use a different replacement set!

    
$vars $DB_site->query("
        SELECT findword,replaceword FROM replacement
        WHERE replacementsetid IN(-1,'
$replacementsetid')
        ORDER BY replacementsetid DESC,replacementid DESC
    "
);
    while (
$var=$DB_site->fetch_array($vars)) {
        if (
$var['findword']!="") {
            if (
$var['findword'] == '{images[i][/i]folder}'
                
or $var['findword'] == '{titl[i][/i]eimage}'
                
or $var['findword'] == '{newthr[i][/i]eadimage}'
                
or $var['findword'] == '{closed[i][/i]threadimage}') {
                
$var['replaceword'] = $bburl '/' $var['replaceword'];
            }
            
$varinf .= 'inf = replace(inf,"'.addslashes($var['findword']).'","'.addslashes($var['replaceword']).'");
'
;
        }
    }

    
$buttonextra="
<SCRIPT LANGUAGE=\"JavaScript\">

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}

function displayHTML() {
var inf = document.name.template.value;
$varinf
win = window.open(\", \", 'popup', 'toolbar=no,status=no,scrollbars=yes,width=800,height=600'); 
You can change the $replacementsetid if you want:
Code:
	$replacementsetid = 1;	### Change me to use a different replacement set!
Enjoy!

Show Your Support

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

Comments
  #42  
Old 05-28-2002, 02:58 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Chen,

I uninstalled the hack and reinstalled it and I get the same javascript errors when I try to use either FIND or PREVIEW. When I uninstalled it, everything went back to working the old way. I can use find and preview now with no errors. Is there any way that I can get this working somehow? It looks like exactly what I need. I'd like to get it working if possible.
Reply With Quote
  #43  
Old 06-20-2002, 11:37 AM
FleaBag's Avatar
FleaBag FleaBag is offline
 
Join Date: Dec 2001
Posts: 1,674
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Working on 2.2.6, thanks FireFly!
Reply With Quote
  #44  
Old 06-21-2002, 01:17 AM
countryboy713 countryboy713 is offline
 
Join Date: Mar 2002
Posts: 61
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i know im a n00b, but i dont quite get what to do where it says addslashes. if thats supposed to be there, then im getting a parse error on line 25 in template.php. any help would be appreciated.
Reply With Quote
  #45  
Old 03-22-2003, 10:10 PM
+d-cipher +d-cipher is offline
 
Join Date: Dec 2002
Location: NY
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anybody get this working with 2.2.9?
Reply With Quote
  #46  
Old 04-25-2003, 06:35 PM
Kurayami's Avatar
Kurayami Kurayami is offline
 
Join Date: Sep 2002
Location: California
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not working on 2.3.0, unfortunately... I get the aforementioned parse error at line 25.
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 09:53 AM.


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.04360 seconds
  • Memory Usage 2,265KB
  • Queries Executed 20 (?)
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)bbcode_code
  • (2)bbcode_php
  • (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
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (6)postbit_onlinestatus
  • (6)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