View Full Version : Preview and copy buttons for Edit Template
Ok don't give me a bunch of crap if I'm posting this wrong, this is my first little contribution to VB.
In the short time I've been playing around with VB, I've already become annoyed at editing templates. I added two little javascript buttons to the page to make things easier.
Copy - click the button to highlight all the text in the textarea and copy it to the clipboard in one step
Preview - opens a new window displaying the html from the message area. It doesn't replace the variables with any value, but does gives you an idea of layout and color changes
for VB v2.0.1
updated attachment below
Philipp
06-28-2001, 10:49 PM
Nice hack. I try it tomorrow :)
and welcome aboard Mutt ;)
Raptor
06-30-2001, 12:17 AM
doesnt work
and yes i did change the php3 to php ;)
what didn't work?
maybe I left something out
I edited the directions so try it again
the forum seems to be spliting the word javascript up into 2 words java and script with a space between them. make sure you remove that space
Hey there, I was doing alot of template editing today and needed an easy way to search an individual template. It got so bad that I finally added one.
new feature
Find - adds a small input field and a form button so you can search the textarea. very handy
While editing the directions I realized that I left out a step before. This attachment has complete instructions and all 3 features. I also moved the buttons for esthetic reasons.
MrLister
07-04-2001, 02:52 AM
great job! looks usefull. i'll try it right now
webhost
07-04-2001, 12:45 PM
Thanks Mutt , this will help out alot. I would recommend this to anyone. The only problem I see sometimes is the way the preview turns out, not enough to matter though.
Great Job.
Originally posted by Mutt
Ok don't give me a bunch of crap if I'm posting this wrong, this is my first little contribution to VB.
In the short time I've been playing around with VB, I've already become annoyed at editing templates. I added two little javascript buttons to the page to make things easier.
Copy - click the button to highlight all the text in the textarea and copy it to the clipboard in one step
Preview - opens a new window displaying the html from the message area. It doesn't replace the variables with any value, but does gives you an idea of layout and color changes
for VB v2.0.1
updated attachment below
Getting dizzy here!! Where is it?????
webhost
07-04-2001, 01:37 PM
In your admin control panel under templates. This adds copy,preview, and find buttons to the box you view when looking at your templates.
You select copy it copies all in the template you are looking at for clipboard pasting, Select find and you can search the template you are viewing fot strings. Select preview and you can preview the template.
Damn!!! This is useful ;) ;)
fantastic hack! That bloody 'find' is brilliant
pestilence
07-06-2001, 08:32 AM
wheres the attachment for this hack went to ?
BluSmurf
07-06-2001, 09:06 PM
woooowwwwwwwwwww!!! GREAT HACK! :D
Originally posted by pestilence
wheres the attachment for this hack went to ?
6th post from the top :)
what can I say Mutt
you were great with UBB and I think you will be one of the greatest with VB
very very well done :)
zarkov
07-07-2001, 11:48 PM
Class hack m8, less than 30 secs to install.
I could have done with this 2 days ago lol.
:)
Johnny
07-08-2001, 02:42 PM
can you maybe put it so in a post that you very good can see what you exactly must change??
in the attachment everything is uhh... how can i say this in english... in dutch it is: alles staat naast elkaar van wat je moet doen!
can you maybe do it so:
templates to edit:
and then bv: find in the template ..... and place after it ....
tnx!
Killer
Johnny
07-09-2001, 12:09 PM
can maybe someone tell it me how to install!
the file is not so clear!
can it maybe like this thread: http://vbulletin.com/forum/showthread.php?threadid=22148
tnx
Johnny
Johnny
07-11-2001, 11:39 AM
ok here's another post from me! :(
i don't know why the people here don't tell me the answer on my questions!
In the attachtmentAdds some helpful features to the admin edit template page - Highlight All and Copy - Quick & Dirty Preview Template - Find in template Made By Mutt VB2.0.1 edit templete.php right at the begining of the script just after function displayHTML() { var inf = document.name.template.value; win = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes'); win.document.write(\"\" + inf + \"\"); } function HighlightAll() { var tempval=eval(\"document.name.template\") tempval.focus() tempval.select() if (document.all){ therange=tempval.createTextRange() therange.execCommand(\"Copy\") window.status=\"Contents highlighted and copied to clipboard!\" setTimeout(\"window.status=''\",1800) } } var NS4 = (document.layers); // Which browser? var IE4 = (document.all); var win = window; // window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == '') return false; if (NS4) { if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; if (n == 0) alert('Not found.'); } if (IE4) { txt = win.document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart('character', 1); txt.moveEnd('textedit'); } if (found) { txt.moveStart('character', -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else alert('Not found.'); } } return false; } "; find ###################### Start add ####################### add makelabelcode("","$ButtonExtra"); right before makehiddencode("group", "$group"); find ###################### Start edit ####################### add makelabelcode("","$ButtonExtra"); right before makehiddencode("group", "$group");
ok what must i now change in the template "template.php"??
pleazz tell it me! this is a great hack and i want it too!!!
tnx
Johnny
Ahhhh my find button dont work, damn!!!! what can be wrong??Nothing happends at all. it just clicks,
any suggestions
ShadowTech
07-12-2001, 05:47 AM
The find feature doesn't work for me either.. there must be some wrong coding in the java cause everytime I push the find button I get the Error on Page message in the status bar of IE.
Ok.. after I posted this I went back to the templates to try it again and found out this:
The Find button will ONLY work until you hit the preview button. Once the preview button loads up the new page.. the Find will NO longer work.. simply refresh the template page and the find will work again.. however your code changes will be lost.
It still works after you press copy.. but for some reason it must not like the popup feature of the preview.
Just wanted everyone to know that this works in 2.03 and I fixed the javascript bug that kills find after using the preview. the only changes were where $ButtonExtra is defined.
I'd like to add an undo button. Alt+U will undo changes to the text area and I need a way to make a button that simulates pressing Alt+U. Any ideas? If you know of anything where you can use javascript to make a link simulate a key press, let me know. thanx!
Admin
08-05-2001, 12:19 PM
Tremendous hack!
Very useful, easy to install, simply great! :D
Excellent work, Mutt! Can't beat the ease of installation.
Can anyone make something like this for 2.0.3?
webhost
08-26-2001, 02:32 PM
I am running 2.0.3 runs fine for me.
Did you follow the same instructions or did you have to modify different files?
webhost
08-26-2001, 05:02 PM
i followed same instructions in the opening post of this thread
thanks I look forward to installing. the reason i'm being so annoying is because I wasi nstalling hack before and kept fouling up my forum. now I use all 2.0.3 hacks and they seem to work :D go figure.
Can this hack work with this one? [RELEASE] Template Control Panel for 2.0 (http://vbulletin.com/forum/showthread.php?s=&threadid=8752&perpage=15&pagenumber=1)
webhost
08-26-2001, 05:42 PM
don't know never installed that one
ToraTora!
08-26-2001, 07:50 PM
1) the instructions, seem to say..."edit templete.php right at the begining of the script just after function displayHTML() "
now, I dont know where the function display HTML went, but its not in any template.php file i have. Could this be clarified>?
2) the only function that is shown somewhere even resembling the beginning, is Start search area, which is a quarter of the way down. I might add, there is nothing said about display HTML there either...just this...
function confirmaction(theform) {
if ((theform.searchstring.value=="") || (theform.replacestring.value=="")) {
theform.searchstring.select();
return confirm("WARNING:\n\nYou have chosen to perform a FIND/REPLACE operation on all your templates,\nbut at least one of the fields is empty.\n\nAre you SURE?");
} else {
return true;
}
is there something i am missing here?
The instuctions send mixed signals. Is it function display HTML, is it after the function, we add the code, is it after functionhtml we add code?
Is the php file, template.php, which is found in the admin folder??
Either way, im not finding this elusive display HTML code, and it is on 2.03...
any help would be greatly appreciated.
Is the php file, template.php, which is found in the admin folder??
I added the code to admin/template.php right below "error_reporting(7);" at the top of the file. It works fine that way.
ToraTora!
08-27-2001, 12:08 AM
Originally posted by FWC
I added the code to admin/template.php right below "error_reporting(7);" at the top of the file. It works fine that way.
thank you. I was thinking of doing that myself, however backed out until i recieved a straight answer here.
One last question, and than im off to install this bad boy.
exactly where do you start with the hacked code to add below the error 7?
this?
{ var inf = document.name.template.value; win = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
Thanks again. :)
exactly where do you start with the hacked code to add below the error 7?
I started with:
$ButtonExtra="
I assume that was right because it works. It's really a nice tool to have, too.
ToraTora!
08-27-2001, 05:08 AM
one thing i was going to ask about, was the preview feature. will this actually show a HTML preview of the template>?
It looks to me like a very usefull hack. The documentation is a little loose on the edges, but other than that, it sounds like he did one hell of a job on it.
ToraTora!
08-27-2001, 05:23 AM
Here is the problem I add that long code, under the error 7,
{ var inf = document.name.template.value; wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes'); wintwo.document.write(\"\" + inf + \"\"); }
function HighlightAll() { var tempval=eval(\"document.name.template\") tempval.focus() tempval.select() if (document.all){ therange=tempval.createTextRange() therange.execCommand(\"Copy\")
window.status=\"Contents highlighted and copied to clipboard!\" setTimeout(\"window.status=''\",1800) } } var NS4 = (document.layers);
// Which browser? var IE4 = (document.all); var win = window;
// window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == '') return false; if (NS4)
{
if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; if (n == 0) alert('Not found.'); } if (IE4) { txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart('character', 1); txt.moveEnd('textedit'); }
if (found)
{ txt.moveStart('character', -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else alert('Not found.');
} } return false; } ";
Now i am getting a parse error, on line three, which is the code under the error 7.
Any hints?
This documentation needs work.
I had the same problem the anser is in the error. I think its like template.php and you'll see the rroer infront of <?php or something. I got the same thing I installed the hack by the instructions..goodluck that fix worked for me
ToraTora!
08-27-2001, 05:34 AM
well, i pulled it out. The documentation doesnt warrent my attention any longer. There is no way of knowing where this thing starts, or where it ends.
It's a great code man, try again. Follow it eactly, I'm a newbot I got it. I installed like 5 hacks today on my new forum. Some for me to make my life easier and some for the users. Re-up your orig files and start from scratch. It's really worth it.
Any hints?
You need the first three lines:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
It works fine with them.
ToraTora!
08-27-2001, 05:44 AM
ok, i will, but give me a breakdown of what you did, because i may be adding code, that has nothing to do with actually being there, since the documentation runs altogether like it does..
something like this..
Find blah.
report error 7
add
blah
find
blah blah
add
blah blah blah
If you could do that for me Lubi, it would be most appreciated. :)
ToraTora!
08-27-2001, 05:46 AM
Originally posted by FWC
You need the first three lines:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
It works fine with them.
See, i dont even see that line anywhere in the documentation...im going fuc*ing blind i think...
ToraTora!
08-27-2001, 05:47 AM
this is all done, within the admin/template.php file correct?
I mean, there isnt some other file, or some other template possibly that im missing here...
ToraTora!
08-27-2001, 05:51 AM
still getting the same error.....beats the hell out of me..
This was in the documentation I got:
Adds some helpful features to the admin edit template page
- Highlight All and Copy
- Quick & Dirty Preview Template
- Find in template
Made By Mutt
VB2.0.3
updated 08-03-01
edit templete.php
right at the begining of the script just after
<?php
error_reporting(7);
add
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
There is the first line you added and the three above it. There should haved been a space between the "add" and the first line of code.
this is all done, within the admin/template.php file correct?
Yes. The code you displayed before wasn't formatted correctly. Mine starts like this:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
wintwo.document.write(\"\" + inf + \"\");
}
ToraTora!
08-27-2001, 06:02 AM
ok, here is what i got so far...
add after report error 7
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
Find
// ###################### Start add #######################
makehiddencode("group", "$group");
and add above that line:
makelabelcode("","$ButtonExtra");
Find
// ###################### Start edit #######################
makehiddencode("group", "$group");
and add above that line:
makelabelcode("","$ButtonExtra");
than of course, you have all of this...and that is the problem, as well as no closing tag for the java script...
{ var inf = document.name.template.value; win = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes'); win.document.write(\"\" + inf + \"\"); } function HighlightAll() { var tempval=eval(\"document.name.template\") tempval.focus() tempval.select() if (document.all){ therange=tempval.createTextRange() therange.execCommand(\"Copy\") window.status=\"Contents highlighted and copied to clipboard!\" setTimeout(\"window.status=''\",1800) } } var NS4 = (document.layers); // Which browser? var IE4 = (document.all); var win = window; // window to search. var n = 0; function findInPage(str) { var txt, i, found; if (str == '') return false; if (NS4) { if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; if (n == 0) alert('Not found.'); } if (IE4) { txt = win.document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart('character', 1); txt.moveEnd('textedit'); } if (found) { txt.moveStart('character', -1); txt.findText(str); txt.select(); txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else alert('Not found.'); } } return false; } ";
Where does all of that, go....lol
ToraTora!
08-27-2001, 06:06 AM
Originally posted by FWC
Yes. The code you displayed before wasn't formatted correctly. Mine starts like this:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
wintwo.document.write(\"\" + inf + \"\");
}
well, that explains a little bit...my question now, would be...is that all that is needed under the error7 area?
It should be that code above, (your code) the code in the start search, and start edit..and thats it?
I mean...i feel like i have completely different documentations here than what you guys have..lol.
ToraTora!
08-27-2001, 06:07 AM
also, doesnt there have to be a closing </SCRIPT>
in there as well?
Here's exactly what I have added:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
wintwo.document.write(\"\" + inf + \"\");
}
function HighlightAll() {
var tempval=eval(\"document.name.template\")
tempval.focus()
tempval.select()
if (document.all){
therange=tempval.createTextRange()
therange.execCommand(\"Copy\")
window.status=\"Contents highlighted and copied to clipboard!\"
setTimeout(\"window.status=''\",1800)
}
}
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == '')
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert('Not found.');
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if (found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
} else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert('Not found.');
}
}
return false;
}
</script>
<input name='string' type='text' size=20 onChange='n=0;'>
<input type='button' value='Find' onClick='javascript:findInPage(document.name.strin g.value)'>
<input type='button' value='Preview' onclick='javascript:displayHTML()'>
<input type='button' value='Copy' onclick='javascript:HighlightAll()'>";
Then the normal admin/template.php begins again.
ToraTora!
08-27-2001, 06:18 AM
Originally posted by FWC
Here's exactly what I have added:
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
wintwo.document.write(\"\" + inf + \"\");
}
function HighlightAll() {
var tempval=eval(\"document.name.template\")
tempval.focus()
tempval.select()
if (document.all){
therange=tempval.createTextRange()
therange.execCommand(\"Copy\")
window.status=\"Contents highlighted and copied to clipboard!\"
setTimeout(\"window.status=''\",1800)
}
}
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == '')
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert('Not found.');
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if (found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
} else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert('Not found.');
}
}
return false;
}
</script>
<input name='string' type='text' size=20 onChange='n=0;'>
<input type='button' value='Find' onClick='javascript:findInPage(document.name.strin g.value)'>
<input type='button' value='Preview' onclick='javascript:displayHTML()'>
<input type='button' value='Copy' onclick='javascript:HighlightAll()'>";
Then the normal admin/template.php begins again.
Ok, there is the first opening lines of the script...than a person does the other two little mods, and that should be it...
Thanks for your help..it is greatly appreciated. If anything, we helped document this mess for him. :)
i will go try it out, and if this doesnt work, i am not going to bother with it. lol...had enough of it, as i am sure you have had enough of me asking for help. :)
again, thanks FWC, and LuBi for your time and concern to my moronic ignorance that has plagued me with this hack.
Catch ya in a bit.
again, thanks FWC, and LuBi for your time and concern
No problem. I'm no programmer. I'm sure you'll help me much more in the future. :D
ToraTora!
08-27-2001, 06:23 AM
did you get any java errors with this? I got three rite as i opened up the template area....UGGGG!!!
So, we have the lines you have above, rite under error, and than the other two...now what?>
ToraTora!
08-27-2001, 06:27 AM
it is conflicting with the start generate files of line 93,94,95,
which is the db query for the templates....
We're out of my league now. I compared my modified file with my original file. That code was all I added. The first couple lines of the original template.php after the hack are:
f ($action=="customize") $action="add";
if (isset($action) and $action=="generate") {
$noheader=1;
}
require("./global.php");
adminlog(iif($templateid!=0,"template id = $templateid",iif($templatesetid!=0,"templateset id = $templatesetid","")));
ToraTora!
08-27-2001, 06:33 AM
here we go again....
Under report error 7 ADD
$ButtonExtra="
<SCRIPT LANGUAGE=\"JavaScript\">
function displayHTML() {
var inf = document.name.template.value;
wintwo = window.open(\", \", 'popup', 'toolbar = no, status = no, scrollbars=yes');
wintwo.document.write(\"\" + inf + \"\");
}
function HighlightAll() {
var tempval=eval(\"document.name.template\")
tempval.focus()
tempval.select()
if (document.all){
therange=tempval.createTextRange()
therange.execCommand(\"Copy\")
window.status=\"Contents highlighted and copied to clipboard!\"
setTimeout(\"window.status=''\",1800)
}
}
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == '')
return false;
if (NS4) {
if (!win.find(str))
while(win.find(str, false, true))
n++;
else
n++;
if (n == 0)
alert('Not found.');
}
if (IE4) {
txt = win.document.body.createTextRange();
for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
txt.moveStart('character', 1);
txt.moveEnd('textedit');
}
if (found) {
txt.moveStart('character', -1);
txt.findText(str);
txt.select();
txt.scrollIntoView();
n++;
} else {
if (n > 0) {
n = 0;
findInPage(str);
}
else
alert('Not found.');
}
}
return false;
}
</script>
<input name='string' type='text' size=20 onChange='n=0;'>
<input type='button' value='Find' onClick='java script:findInPage(document.name.string.value)'>
<input type='button' value='Preview' onclick='java script:displayHTML()'>
<input type='button' value='Copy' onclick='java script:HighlightAll()'>";
Find //////// start search///////////
and the line within that that reads:
makehiddencode("group", "$group");
and replace it with:
makelabelcode("","$ButtonExtra");
Find ////////start edit//////////
and the line within that reads:
makehiddencode("group", "$group");
and replace it with:
makelabelcode("","$ButtonExtra");
Now..that should be all there is to it correct?
ToraTora!
08-27-2001, 06:37 AM
Originally posted by FWC
We're out of my league now. I compared my modified file with my original file. That code was all I added. The first couple lines of the original template.php after the hack are:
f ($action=="customize") $action="add";
if (isset($action) and $action=="generate") {
$noheader=1;
}
require("./global.php");
adminlog(iif($templateid!=0,"template id = $templateid",iif($templatesetid!=0,"templateset id = $templatesetid","")));
ok, that explains a huge void here. You only added that chunk of code. I have two extra things that were supposed to be entered......this is my biggest bitch and complaint on some of these hacks...piss poor documentation.
I will give that a whirl FW, and if that doesnt do it, fuc* it..it gets ripped out.
Crap, I'm an idiot. I just found this part:
find
###################### Start add #######################
add
makelabelcode("","$ButtonExtra");
right before
makehiddencode("group", "$group");
find
###################### Start edit #######################
add
makelabelcode("","$ButtonExtra");
right before
makehiddencode("group", "$group");
ToraTora!
08-27-2001, 06:47 AM
Still nothing but errors...I reluctantly put this one away...I had the lines above added FW, ($button values)
and that is what was giving the errors. I took them out, everything worked fine..put them back in, and it wiped out my acutal vb buttons...so, this pain in the ass hack is being put to pasture with its lackluster documentation.
Again, I thank you for your patience and help FW, i really do
I'm sorry we didn't get it to work. It's frustrating. I do know I have to get some sleep.
ToraTora!
08-27-2001, 06:55 AM
very frusterating.....
i cannot tell you in words how many times i have tried to get this thing to work, so there comes a time when you just have to say "fuc* it" lol...
ok, catch ya later, and again, thanks for the help.
Sleep....sounds like a good idea..
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.