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.
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
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...
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']).'");