Welcome to Geeklog, Anonymous Saturday, December 21 2024 @ 01:36 pm EST
Geeklog Forums
Loading of JavaScript in HTMLAREA
Anonymous
Anonymous
Yesterday, I installed HTMLArea (download here) on my GL site. I'm quite pleased with its WYSIWYG features, and I think it provides me and my users a much easier interface for submitting new stories.
Checking my logs, I see that editor.js is loaded (about 40K) whenever visitors first hit my website. This is no doubt from putting it within my [header] of my theme's header.thtml.
Since submitting articles is the exception rather than the rule, it makes sense to only load the javascript if the user hits the "Submit Story" page. Is it possible to implement this, or is the fact that it must be contained within the [header] going to prevent me from doing this?
12
14
Quote
Status: offline
rawdata
Forum User
Full Member
Registered: 02/17/03
Posts: 236
This can be done with a conditional statement to include it only when the relevant pages are called. There's probably a couple ways you can to do it. One way is to set up a global variable like this in lib-custom.php or config.php:
$_CONF['custom_tag'] = '';
Then, inside the functions or files which generate the pages you want the HTMLArea javascript loaded (submit.php or comment.php or whatever) add this new global variable and set it to something else like:
$_CONF['custom_tag'] = 'htmlarea';
If you add this variable inside a function, make sure $_CONF is declared as a global. If it's not already declared as such, then add this to the top of the function:
global $_CONF;
Set the path and filename in this conditional statement to the correct ones then replace the htmlarea script tag you currently have in header.thtml with this snippet.
<?php
if ($_CONF['custom_tag'] == 'htmlarea') {
echo('<script src="<path to your htmlarea js>/filename.js" type=text/javascript></script>');
}
?>
I think this should give you the effect you're seeking.
12
15
Quote
All times are EST. The time is now 01:36 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content