Version: 1.00, by Admin (Coder)
Developer Last Online: Nov 2024
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.
$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.
Did it add any extra load to the site? The reason I am asking is I just got it set up on my site and think it is the greatest thing to come along on any system. Do you still have it for the larger code or is it gone altogether? Can it be set up for a certain length of code or higher?
Quote:
Originally posted by FireFly I removed it Boofo, it became annoying when you just want to copy a small portion of the code.