Jump to content
xisto Community
Hercco

Forum post templates! Using javascript

Recommended Posts

I guess I'll better start by explaining by what I mean by these post templates.

 

The idea came to me as one online-friend of mine has a habit of posting all his posts with same colour on a certain forum. We had previously talked how it would be cool if vBulletin (in this case) would have option to save a "post template" which it would automatically load to textarea everytime a new reply or thread is posted.

 

Well as it is not implemented on the server side, why not do it clientside! What you may have not realized is that "bookmark toolbar" or "personal bar" bookmarks (the links usually at the top of your browser window, below location field) can be used quite similarly as links on an html-page. And thus can be used to execulte Javascript.

 

So simply create a new "personal bar" (or whatever, depending on your browser) link and paste one of the following codes into the "location" field. And naturally make your changes before saving it.

 

 

 

This is for vBulletin:

javascript: window.document.vbform.message.value='[color=Burlywood]'+window.document.vbform.message.value+'[/color]';window.stop();

For phpBB:

 

javascript: window.document.post.message.value='[color=Burlywood]'+window.document.post.message.value+'[/color]';window.stop();

And for Invision:

 

javascript: window.document.REPLIER.Post.value='[color=Burlywood]'+window.document.REPLIER.Post.value+'[/color]';window.stop();

Even if you are not familiar with javascript you can probably understand what these scripts fo. they simply add "" in front and "" after the contents of the message.

 

Naturally you can change the contents anyway you want to make it add any tags and text you want there. For example some ASCII art would be quite neat at the beginning or end of all your posts.

 

For those who do not know JS: you can use '\n' to make line change and '\t' for tabulation.

 

 

One annoying thing about this is that, if you want to use same template for different forums using different forums software you will have to have separate links for each. One way to get around this could be writing a script that checks which elements exists and adds the template to the one that's real.

 

 

Hopefully someone will find this useful.

Share this post


Link to post
Share on other sites

definitely a nice tutorial and idea... could really be expanded... i like this idea alot... but i have a question... how do actually make a personal bar in ie and do this? actually the reason i wanted to understand this is becuz i wanted to make a forum like software comparable to vbulletin in near future... i dunno if i would succeed or nt but its the first piority in my mine right now after i complete my exam... so something like this for my forum would be an excellent... or an advantage... :) and can make my forum more customizable... and flexible... or wadever it is... could u explain the steps in detail? :) thank u in advance... :P its so cool...

Share this post


Link to post
Share on other sites

I think the easiest was is to make a link in HTML page and simply drag it to the bar.

And about your own forum, why not make it server side? Allow users to change their template from a user control panel and possibly a button in the posting page for adding template to post.

Other neat trick with personal bar links and javascript is is grabbing information of a website. I have a links database system at my website (here) and to add links I use a button at browser personal bar.

What is does is grabs the sites that I am on title and url and simply with window.open() opens a new window for which it requests a PHP page with the page url and title as get variables (eg. quicklink.php?url=<url_here>&title=<title_here> ). The php page (quicklink.php) processes the get data and adds them as default values to a form. Then I just make my changes, write a description of the site and hit submit and the link appears to the database.

Share this post


Link to post
Share on other sites

wow... thats very handy tool! i gonna pick up javascript after my java and jsp... lolz... anyway... i dunno whether i gonna put it in server side becuz that gonna eat up some database if i gonna let people do have this option... i dunno... but having it as an option is better den not having it i guess... lolz... tks man... this is very very cool...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.