SimplePortal

Support => English Support => Topic started by: Matt5L on December 03, 2008, 10:22:23 PM

Title: Trying to get a image via .JS at the top of my theme
Post by: Matt5L on December 03, 2008, 10:22:23 PM
I know this isnt a simple portal question but you guys seem to be super smart so ill ask here.

My forum is here:
http://sn95forums.com/index.php

Im trying to add this javascript in:
http://sn95forums.com/banners/randomcarimage.js

I want it to go where the current banner is, its a random image java script.  I cant find where to enter the code, index template?  Its kind of an odd script.

Also I tried to test load the script with the following code in a html page:
Code: [Select]
<SCRIPT language="JavaScript" SRC="http://sn95forums.com/banners/randomcarimage.js"></SCRIPT>
But it doesn't load, what am I doing wrong, the only way I can get it to load is to paste the entire script in the html page and I would perfer not to have to do that.

Thanks!
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: Burke Knight on December 03, 2008, 11:47:47 PM
Wherever you want it to show. Just make sure it is after the <body> tag, but before the </body> closing tag.
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: Matt5L on December 04, 2008, 12:25:23 AM
I try that but I keep getting errors:

Template Parse Error!
There was a problem loading the /Themes/morestyle/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .../Themes/morestyle/index.template.php on line 300

291:    </div>
292:    <script language="JavaScript"><!--
293:
294: //Javascript Created by SN95FORUMS http://www.sn95forums.com
295:
296: //store the quotations in arrays
297:
298: images = new Array(4);
299:

300: images[1] = "<img src='http://www.sn95forums.com/banners/1.jpg'></a>";

301:
302: images[2] = "<img src='http://www.sn95forums.com/banners/2.jpg'></a>";
303:
304: images[3] = "<img src='http://www.sn95forums.com/banners/3.jpg'></a>";


Can I just use the code similar to <SCRIPT language="JavaScript" SRC="http://sn95forums.com/banners/randomcarimage.js"></SCRIPT>  instead of all of that? I know there is a way and not sure why that wont work?

Thanks
Matt
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: Jade Elizabeth on December 04, 2008, 12:35:50 AM
Yes, you should..

If you attach your index.template.php file I can attempt it for you :)
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: Matt5L on December 04, 2008, 01:17:54 AM
attached thanks!!!!
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: Matt5L on December 04, 2008, 11:21:46 PM
Any updates?

Thanks,
Matt
Title: Re: Trying to get a image via .JS at the top of my theme
Post by: [SiNaN] on December 20, 2008, 07:16:52 AM
Well, I had a few minutes to try that but couldn't get it work. I don't know Js, but I know PHP...

Create a PHP file with this codes in your root directory:

Code: [Select]
<?php
header
('Content-Type: image/jpeg');
@
readfile(dirname(__FILE__) . '/banners/' mt_rand(140) . '.jpg');
?>

Then your random image url will be like this:

http://yoursite.com/nameofthephpfile.php

You can add this HTML code to your index.template.php, where you want to show it:

<img src="http://yoursite.com/nameofthephpfile.php" alt="banner" />

Hope it helps.
SimplePortal 2.3.8 © 2008-2024, SimplePortal