Javascript in connectivity

wes 17 Feb, 2009
Hi,

I'm trying to get de following into CC but it doesn't seem to work:

In the Header:
<SCRIPT src="http://www.test.com/js/swfobject.js" 
type=text/javascript></SCRIPT>


In the Body
<SCRIPT type=text/javascript>
	var fo = new FlashObject ("http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=Teams", "nix", "390", "23", "7", "#FFFFFF");
	fo.addParam("wmode", "transparent");
	fo.write("flashHeader_Teams");
</SCRIPT>


But it gives an error, what am i doing wrong. When i use this code in an HTML page, it works without an problem.

Regards,

Wes
wes 17 Feb, 2009
The help text, gives the answer about which code is allowed. But is there a way to implement it? I can use an include, but for one of the connections it has to be a variabele like:

<SCRIPT type=text/javascript>
	var fo = new FlashObject("http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=<?php
echo JRequest::getString('team', ' ', 'get');?>", "nix", "390", "23", "7", "#FFFFFF");
	fo.addParam("wmode", "transparent");
	fo.write("flashHeader_teamdetails");
</SCRIPT>


Regards,

Wes
GreyHead 17 Feb, 2009
Hi wes,

Try this
<?php
$team = JRequest::getString('team', ' ', 'get');
$url = "http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=$team";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration('var fo = new FlashObject($url, "nix", "390", "23", "7", "#FFFFFF");
fo.addParam("wmode", "transparent");
fo.write("flashHeader_teamdetails");');
?>
Note: not tested and may need debugging.

Bob
wes 17 Feb, 2009
Hi Bob,

Thanks for the direction, but ain't the <SCRIPT> tags missing? I'm rather new tot php, so perhaps it's a silly question.

Regards,

Wes
GreyHead 17 Feb, 2009
Hi wes,

The $doc->addScriptDeclaration() is a Joomla command that should add the tags and load the script snippet in the header.

Bob

PS There was a stray space in my post that I've now edited out.
wes 21 Feb, 2009
Hi,

I've been trying the code (and variants of it) but the code is placed in de HEADER of the page between the <HEAD> and </HEAD> and the URL is not translated, so the code created is the following:

  <script type="text/javascript">
var fo = new FlashObject($url, "nix", "390", "23", "7", "#FFFFFF");
fo.addParam("wmode", "transparent");
fo.write("flashHeader_team");
  </script>


When i use for example some <DIV> tags in the HEADER field of CC the result it is shown in the place i want it to be. Perhaps the cause is the $url, but i'm not sure

Regards,

Wes

P.S. Sometimes i get 'FlashObject' is not defined. It is defined in the JS which the page calls but the code above is placed before it in the header. I think that's the cause of the error
GreyHead 21 Feb, 2009
Hi wes,

I didn't update the quotes correctly, please try:
<?php
$team = JRequest::getString('team', ' ', 'get');
$url = "http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=$team";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration('var fo = new FlashObject('.$url.', "nix", "390", "23", "7", "#FFFFFF");
fo.addParam("wmode", "transparent");
fo.write("flashHeader_teamdetails"););
?>

Bob
wes 21 Feb, 2009
Hi Bob,

Thanks again. I tried the quotes before, but i missed the dots. But it still doens't work. I changed the code to (with the dubble quotes around the URL, i don't know the english word for it) and added the div for showing:

<DIV class=flashHeader id="flashHeader_teamdetails"></DIV>
<?php
$team = JRequest::getString('team', ' ', 'get');
$url = "http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=$team";
$doc =& JFactory::getDocument();
$doc->addScriptDeclaration('var fo = new FlashObject("'.$url.'", "nix", "390", "23", "7", "#FFFFFF");
fo.addParam("wmode", "transparent");
fo.write("flashHeader_teamdetails");');
?>


The result is (which is correct):

  <script type="text/javascript">
var fo = new FlashObject("http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=Team 1", "nix", "390", "23", "7", "#FFFFFF");
fo.addParam("wmode", "transparent");
fo.write("flashHeader_teamdetails");
  </script>


But it is still in the HEAD of the page and not wihtin the CC form. The DIV part is displayed in the CC form part:

<form action="index.php?option=com_chronoconnectivity&connectionname=Teamdetails" method="post" name="connectivity">
	
	<DIV class=flashHeader id="flashHeader_teamdetails"></DIV>

<div class="content">


Regards,

Wes
Max_admin 21 Feb, 2009
Hi Wes,

I'm not sure but, should the code be in the same place with the DIV ? I think there is no need for this, at least I never seen some code which should be... :?

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 22 Feb, 2009
Hi Wes,

No it doesn't need to be in the same place as the div, it does need to load after the swfobject.js file though.

I ran a test and all was OK - there was a error in the swfobject setup but I think that may be a version setup difference - didn't dig too far.

Bob
wes 22 Feb, 2009
Hi Bob,

Are you referring to an 'null' is empty or not an object error? I created a php page with the same script. It works fine if the order is:

- Load js file
- DIV
- Javascript entry

Code:
<HTML>
<HEAD>
<SCRIPT src="http://www.test.com/js/swfobject.js" 
type=text/javascript></SCRIPT>
</HEAD>
<BODY>
<DIV class=flashHeader id="flashHeader_teamdetails"></DIV>
<SCRIPT type=text/javascript>
	var fo = new 
FlashObject("http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=Sponsor", "nix", "390", "23", "7", "#FFFFFF");
	fo.addParam("wmode", "transparent");
	fo.write("flashHeader_teamdetails");</SCRIPT>
</BODY>
</HTML>


When the part

<SCRIPT type=text/javascript>
	var fo = new 
FlashObject("http://www.test.com/swf/pageHeaderVrienden.swf?headerVar=Team", "nix", "390", "23", "7", "#FFFFFF");
	fo.addParam("wmode", "transparent");
	fo.write("flashHeader_teamdetails");</SCRIPT>


is before the DIV tag the 'null' error occurs. So the script has te be loaded as last and within CC this doesn't happen. CC puts it in the header and so it is 'loaded' before the DIV tag. Do you think the cause is due an error in the js file?

Regards,

Wes
Max_admin 22 Feb, 2009
Hi Wes,

Ok, back to your first post here, whats the error you get when you add it to the body ?

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
wes 24 Feb, 2009
Hi Max,

I found the problem, the javascript works now. I went back, at your suggestion, to the first post and started again. Thanks.

Regards,

Wes
Max_admin 24 Feb, 2009
Hi Wes,

Great news, If you can post the reason of the problem then this would be great!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
wes 01 Mar, 2009
Hi Max,

It's a third party solution and de JS have to after the DIV. I think it didn't done that the first time.

Regards,

Wes
This topic is locked and no more replies can be posted.