Spice Up Wordpress with Resizable Comment Boxes

Isn't that beautiful?
The style of Switch On The Code is based on a heavily modified version of the Bitter Sweet theme. All-in-all we've really enjoyed this theme - except when it comes to the comment box. It was made a little too small and we've never gotten around to fixing it - until now. Sure we could have simply edited the theme files to make the box bigger, but where's the fun in that?
First off, we really wanted to make this a plugin for Wordpress, but it doesn't look like the plugin system easily supports changes to the comment box - it's more of a theme thing. That means to actually use resizable textboxes we're going to have to get our hands dirty modifying the theme's source files. Fortunately, The Tallest designed the textbox to be nice and modular so the code required is as small as possible.
The first thing we need to do is find the PHP file to modify. The file is called "comments.php" and is stored in your theme's folder inside the Wordpress "themes" folder. I know that sounds confusing, so here's a picture to help clear things up a little.

As you can see, the file I had to modify was stored in the folder, "bitter-sweet-10". Yours will be located in the folder for whatever theme you've decided to use.
Now that you've found the file to modify, we need to find what part of the file to change. This can be wildly different depending on how your theme was implemented, but basically you need to find the
textarea inside this file. For our theme, it was located on line 124.
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
All we have to do is replace that line with our resizable textbox code.
<script type="text/javascript"
src="/files/Resizable_Textbox/javascript.js">
</script>
<link rel="stylesheet"
href="/files/Resizable_Textbox/style.css"
type="text/css" media="screen" />
<span id="commentContainer"></span>
<script type="text/javascript">
var rt = new ResizeableTextbox();
rt.SetCurrentWidth(290);
rt.SetCurrentHeight(200);
rt.SetMaxWidth(525);
rt.SetMaxHeight(600);
rt.GetTextArea().id = 'comment';
rt.GetTextArea().name = 'comment';
var mySpan = document.getElementById('commentContainer');
mySpan.appendChild(rt.GetContainer());
rt.StartListening();
</script>
src="/files/Resizable_Textbox/javascript.js">
</script>
<link rel="stylesheet"
href="/files/Resizable_Textbox/style.css"
type="text/css" media="screen" />
<span id="commentContainer"></span>
<script type="text/javascript">
var rt = new ResizeableTextbox();
rt.SetCurrentWidth(290);
rt.SetCurrentHeight(200);
rt.SetMaxWidth(525);
rt.SetMaxHeight(600);
rt.GetTextArea().id = 'comment';
rt.GetTextArea().name = 'comment';
var mySpan = document.getElementById('commentContainer');
mySpan.appendChild(rt.GetContainer());
rt.StartListening();
</script>
Pretty simple, right? We simply added the Javascript file, CSS file, a container object, and a few lines of Javascript code and everything is up and running. The resizable textbox will be placed inside the
span tags by the Javascript code. We chose to use a span because now when the box is resized, the contents below the page will move up and down with the textbox. All the files referenced here can be downloaded from the Resizable Textbox tutorial posted earlier. I'm not going to go into any details on what those few lines of Javascript code are doing - if you want to know, I would suggest checking out that tutorial.
And that's it for making your Wordpress comment box resizable. You can check out the results for yourself by leaving us a comment.
Update: November 13th, 2007
We simplified the process of adding the resizable textbox. You can now put in the following code instead of what is listed above. Hopes this makes things easier.
<script type="text/javascript"
src="/files/Resizable_Textbox/javascript.js">
</script>
<link rel="stylesheet"
href="/files/Resizable_Textbox/style.css"
type="text/css" media="screen" />
<span id="rtContainer">
<script type="text/javascript">
var rt = new ResizeableTextbox('comment');
rt.SetCurrentWidth(290);
rt.SetCurrentHeight(200);
rt.SetMaxWidth(525);
rt.SetMaxHeight(600);
</script>
</span>
src="/files/Resizable_Textbox/javascript.js">
</script>
<link rel="stylesheet"
href="/files/Resizable_Textbox/style.css"
type="text/css" media="screen" />
<span id="rtContainer">
<script type="text/javascript">
var rt = new ResizeableTextbox('comment');
rt.SetCurrentWidth(290);
rt.SetCurrentHeight(200);
rt.SetMaxWidth(525);
rt.SetMaxHeight(600);
</script>
</span>
Posted in Wordpress, All Tutorials by The Reddest |

December 7th, 2007 at 9:47 pm
Sick… we were just searching for this. Thanks for posting in such detail. You can see the original version above - it looks horrible.
out…
March 11th, 2008 at 8:24 am
ye good but it doesnt work on my site, can this work in dreamweaver?
March 11th, 2008 at 8:30 am
and please please meake it clearer
May 16th, 2008 at 10:27 am
hey just testing nice box thing
August 28th, 2008 at 6:03 am
ye good but it doesnt work on my site, can this work in dreamweaver?
November 10th, 2008 at 6:01 pm
nice! can u explain clearer, because this works only on my test pages (html and php) but not with wordpress!?
thanks
November 10th, 2008 at 6:11 pm
ok, it works, thanks!