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.
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.
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.