Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help - Adding Javascript inside PHP define() of english/index.php


adammde

Recommended Posts

Hi,

 

I'm sure this is stupidly easy, hope someone can help :)

 

I want to put some Javascript inside the define() function of includes/languages/english/index.php, but because the stop character is ; for both JS and PHP, I can't directly, and I don't think I can nest the echo function inside define().

 

I have linked to some separate JS files which works fine, but I really don't want another file just for three lines of JS unless I have to.

 

Any ideas?

 

Thanks, Adam

Link to comment
Share on other sites

As a temporary workaround I put the (now two) lines of JS into a seperate file and linked to it with <script> inside define(), however performance of the script has gone down the toilet completely, no idea why doing it that way makes such a difference.

 

Here's what I'd like to do:

 

define('TEXT_MAIN', '

<p>
<ul id="home_fade" class="crossfade transition-crossfade">
	<li><img src="images/home_fade_dive.jpg" /></li>
	<li><img src="images/home_fade_gun.jpg" /></li>
	<li><img src="images/home_fade_hp.jpg" /></li>
</ul>
</p>

<script type="text/javascript" src="includes/js/prototype.js"></script>
<script type="text/javascript" src="includes/js/effects.js"></script>
<script type="text/javascript" src="includes/js/fastinit.js"></script>
<script type="text/javascript" src="includes/js/crossfade.js"></script>
<script>
Crossfade.setup({autoLoad:true});
var cf1 = new Crossfade('home_fade', {autoStart:true});
</script>

This is a default setup of osCommerce Online Merchant............

 

But of course the PHP parser throws up errors when it reaches the ;

 

I'd really love to find a solution - anyone any ideas?

Thanks, Adam

Link to comment
Share on other sites

Use here-doc whenever you have problems like this ..

 

$mytextjs = 
<<<TEXTJS
<p>
<ul id="home_fade" class="crossfade transition-crossfade">
	<li><img src="images/home_fade_dive.jpg" /></li>
	<li><img src="images/home_fade_gun.jpg" /></li>
	<li><img src="images/home_fade_hp.jpg" /></li>
</ul>
</p>

<script type="text/javascript" src="includes/js/prototype.js"></script>
<script type="text/javascript" src="includes/js/effects.js"></script>
<script type="text/javascript" src="includes/js/fastinit.js"></script>
<script type="text/javascript" src="includes/js/crossfade.js"></script>
<script>
Crossfade.setup({autoLoad:true});
var cf1 = new Crossfade('home_fade', {autoStart:true});
</script>

This is a default setup of osCommerce Online Merchant
TEXTJS;

define('TEXT_MAIN', $mytextjs);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...