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
  #12  
Old 05-22-2002, 06:44 PM
Dalius Dalius is offline
 
Join Date: Oct 2001
Location: Canada!
Posts: 255
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, it would help me alot to have a perfect Preview, with all the variables and images showing
Reply With Quote
  #13  
Old 05-22-2002, 06:56 PM
Xanthine Xanthine is offline
 
Join Date: Mar 2002
Posts: 232
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, I didnt even know there was a preview button. Would there any way to display images or maybe even display the variables?

Thanks again Chen.
Reply With Quote
  #14  
Old 05-22-2002, 07:11 PM
ceo_tfw's Avatar
ceo_tfw ceo_tfw is offline
 
Join Date: Mar 2002
Posts: 87
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

installed, it took 2 minutes and work great, I love it, very smooth
Reply With Quote
  #15  
Old 05-22-2002, 08:03 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Xanthine
Wow, I didnt even know there was a preview button. Would there any way to display images or maybe even display the variables?

Thanks again Chen.
display the images by just replacing {imagefolder} or "images/" with the full URL "http://www.website.com/images/"

only temporarily (just for previews)...if you're asking how to do it without then I'm not too sure...

as for displaying the variables, that would be cool
Reply With Quote
  #16  
Old 05-22-2002, 08:15 PM
CeleronXL's Avatar
CeleronXL CeleronXL is offline
 
Join Date: Nov 2001
Posts: 146
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally posted by Dark_Wizard
Just a word of caution...if your using Mutt's Template Editor this will not work correctly....
Aww... Damn, I just finished installing it too and then I read that. *cries openly*
Reply With Quote
  #17  
Old 05-22-2002, 09:03 PM
c-pr0mpt's Avatar
c-pr0mpt c-pr0mpt is offline
 
Join Date: Oct 2001
Location: Michigan
Posts: 235
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Big time excitement here. I never use preview because its pointless. But this creates a use finally! Thanks
Reply With Quote
  #18  
Old 05-22-2002, 09:53 PM
Siggi Siggi is offline
 
Join Date: Nov 2001
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Many thanks
I use a vb 2.2.1 and have noticed the following error.

Unfortunately, it works this one look for badge in the template no more.

I hope somebody can help me.

Please, my bad one excuses English.
Reply With Quote
  #19  
Old 05-23-2002, 12:57 AM
Neo's Avatar
Neo Neo is offline
 
Join Date: Oct 2001
Location: Anywhere
Posts: 1,817
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

want to make it so it also parses the $variables ?
Reply With Quote
  #20  
Old 05-23-2002, 05:27 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Making it eval() the $variables would be a much more complicated, because you need to set an "example url" for each template, then call it with the temp template. It's not very simple, trust me.

I'll try to fix the images not showing in a minute...
Reply With Quote
  #21  
Old 05-23-2002, 05:34 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, just released a new version and now it also shows you the images.

To upgrade, replace this:
PHP Code:
    global $DB_site;

    
$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']!="") {
            
$varinf .= 'inf = replace(inf,"'.addslashes($var['findword']).'","'.addslashes($var['replaceword']).'"); 
With this:
PHP Code:
    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']).'"); 
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:57 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.04458 seconds
  • Memory Usage 2,341KB
  • 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
  • (1)bbcode_code
  • (4)bbcode_php
  • (2)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
  • (3)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
  • (11)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