vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Better "Preview" for templates in the CP (https://vborg.vbsupport.ru/showthread.php?t=38917)

squawell 05-23-2002 09:55 AM

NICE HACK!! squawell like this one too...thankz..FireFly..:D:D:D

Xelation 05-23-2002 07:25 PM

hmmm, I installed the first part yesterday... and today I did the upgrade for the images... everything is fine except the images still dont show up... you know what could be wrong?......




update, figured out my problem... your code says to search for the word { imagesfolder } (w/o the spaces) erm, I dont use that, I just do images/yaddayaddayadda.gif oh well, never the less its a good hack :)

Mutt 05-23-2002 11:05 PM

Nice job Firefly

When I first added the preview button, I really wanted it to replace the vars but counldn't think of any easy way to do it. I know it was ugly, but I found it better than nothing. It was just some code I found at a javscript site. this is 100% better. a huge improvement.

I read that it didn't work with the template editor. i'll figure it out and see where the conflict is.

thanks again. very cool

Dark_Wizard 05-23-2002 11:13 PM

Quote:

Originally posted by Mutt
Nice job Firefly

When I first added the preview button, I really wanted it to replace the vars but counldn't think of any easy way to do it. I know it was ugly, but I found it better than nothing. It was just some code I found at a javscript site. this is 100% better. a huge improvement.

I read that it didn't work with the template editor. i'll figure it out and see where the conflict is.

thanks again. very cool

Thx Jeff...I was going to look into it but don't have the time right now...

Mutt 05-23-2002 11:34 PM

Fireflys hack is a huge improvement. everyone should install it. Great job!!

I was able to get it working with my advanced template editor. the changes are minimal. function dotemplatejavascript from the advanced template editor is slightly different than the original one. here is the slightly modified version that works with it.

THIS IS ONLY FOR PEOPLE USING THE ADVANCED TEMPLATE EDITOR!!!!!

here is the code to look for
PHP Code:

function dotemplatejavascript() {
global 
$template;
$buttonextra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML(form) {
var inf = form.template.value; 

and replace it with this
PHP Code:

function dotemplatejavascript() {
global 
$DB_site$bburl$template;

    
$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(form) {
var inf = form.template.value;
$varinf 

ONCE AGAIN, THIS IS ONLY FOR PEOPLE USING THE ADVANCED TEMPLATE EDITOR!!

FWC 05-24-2002 05:31 AM

Well done, Firefly! :)

Admin 05-24-2002 06:23 AM

Thanks Mutt! I edited your post BTW, you had replacement in the code. :)

Neo 05-24-2002 02:42 PM

Quote:

Originally posted by FireFly
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...

Hmm looks like something I might try to do, but I just might be insane :confused:

Boofo 05-26-2002 01:08 AM

Whenever I try to preview a template now, I get a Runtime Error. The error says "Line 324" "Object expected". The file is says it is in is the template.php. Here is the code and the line it stops at is the Preview line.

Code:

<input name='string' type='text' accesskey='t' size=20 onChange='n=0;'>
<input type='button' value='Find' accesskey='f' onClick='javascript:findInPage(document.name.string.value)'>&nbsp;&nbsp;&nbsp;
<input type='button' value='Preview' accesskey='p' onclick='javascript:displayHTML()'>
<input type='button' value='Copy' accesskey='c' onclick='javascript:HighlightAll()'></p></td>

I have the better template preview hack AND the images hack installed. Any ideas on this one, anybody? :)

Illuvatar 05-26-2002 08:28 PM

Thanks Firefly!!

And yet another usefull hack that was very easy to install!!

/me bows down!!


All times are GMT. The time now is 11:07 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.01099 seconds
  • Memory Usage 1,764KB
  • 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
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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