How to make my js file work?
Permalink 2 users found helpful
Hi, i'm newly user of c5.
I want my javascript file work on my site.
I just put my js file on the folder below.
../web/concrete/concrete5.3.0/themes/mytheme/elements
and i also put the sentence <script type="text/javascript" src="myjavascript.js"></script> between "<head></head>".
and then i added html in a block by using c5 block (via browsr).
but this doesn't work..
If i wanted to make it work, is this correct way?
sorry if this is a kind of stupid question.
I'm not so good at javascript and php.
I want my javascript file work on my site.
I just put my js file on the folder below.
../web/concrete/concrete5.3.0/themes/mytheme/elements
and i also put the sentence <script type="text/javascript" src="myjavascript.js"></script> between "<head></head>".
and then i added html in a block by using c5 block (via browsr).
but this doesn't work..
If i wanted to make it work, is this correct way?
sorry if this is a kind of stupid question.
I'm not so good at javascript and php.
Thank you so much,
I'll try that way:)
I'll try that way:)
I am trying to include some js also. I have the header line set up as:
<script type="text/javascript" src="<?=$this->getThemePath()?>/as3/swfobject.js"></script>
and my html block as:
<script type="text/javascript">
var so = new SWFObject("banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
All the js stuff is in folder as3 in the concrete root directory. But I am getting nothing displaying when I view the page. The js works on my local machine, but I can't figure out exactly how to make c5 find all the files. Thanks.
<script type="text/javascript" src="<?=$this->getThemePath()?>/as3/swfobject.js"></script>
and my html block as:
<script type="text/javascript">
var so = new SWFObject("banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
All the js stuff is in folder as3 in the concrete root directory. But I am getting nothing displaying when I view the page. The js works on my local machine, but I can't figure out exactly how to make c5 find all the files. Thanks.
ok, I realized the as3 folder needs to be in the theme folder. So the above code is the same, but the as3 folder is located in themes/mytheme/as3. But I still am getting nothing displayed. Do I need to do something special for the location of data.xml?
Here is a block I wrote that I intend to release for free in the marketplace.
It allows you to add typed, or script files to your headers.
You will need to add the ".js" file type in your dashboard allowable file types settings.
Hope this helps.
Chad
It allows you to add typed, or script files to your headers.
You will need to add the ".js" file type in your dashboard allowable file types settings.
Hope this helps.
Chad
Thanks Chad. I installed your block, and tried adding it to a webpage, and pasting what I had in the html block in the previous post. I still see nothing, and this time when I view the source of the displayed html page I don't see anything from this area.
The js files contain a folder with images and a data file, so it would be some work, as well as cumbersome to upload them all into the file manager...
The js files contain a folder with images and a data file, so it would be some work, as well as cumbersome to upload them all into the file manager...
OK, I think I see that your script adds the info to the header. I think I am having trouble when the js file is executing and it isn't finding something - probably the data files?
Here is what is showing up when I view the page:
<div id="HTMLBlock45" class="HTMLBlock">
<script type="text/javascript">
var so = new SWFObject("banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script></div>
Is c5 able to locate the banner.swf and data.xml files as this is written?
thanks again.
<div id="HTMLBlock45" class="HTMLBlock">
<script type="text/javascript">
var so = new SWFObject("banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script></div>
Is c5 able to locate the banner.swf and data.xml files as this is written?
thanks again.
I have been working on this for a couple of hours and I just tried Chad's block again, using it to add the swfobject.js to the files and then to the header. This has enabled the swfobject (yippee), and I see a blank spot on the page where the images should be appearing, but no images.
here is a link to what I am trying to get to work in c5:
http://www.vitalsignsministries.org/concrete5.3.3.1/themes/vsm/as3/...
and here is the c5 page that is partly working:
http://www.vitalsignsministries.org/concrete5.3.3.1/index.php...
Thanks.
http://www.vitalsignsministries.org/concrete5.3.3.1/themes/vsm/as3/...
and here is the c5 page that is partly working:
http://www.vitalsignsministries.org/concrete5.3.3.1/index.php...
Thanks.
Update:
If I change the code in the html block to include the path to the js files:
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "themes/vsm/as3/banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
Then when the page loads I see a rotating icon in the center of the area where the images should appear, for a second, like the file is loading, but still no images...
Thanks.
If I change the code in the html block to include the path to the js files:
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addVariable("dataPath", "themes/vsm/as3/banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
Then when the page loads I see a rotating icon in the center of the area where the images should appear, for a second, like the file is loading, but still no images...
Thanks.
Hurray. I finally ran across another forum post that helped me out:
http://www.concrete5.org/community/forums/usage/flash-galleries-xml...
When I changed my code to the following the images began appearing:
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addParam("base", "themes/vsm/as3/");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
The line beginning with so.addParam("base"... did the trick. I wish I could add some more useful information to help out anyone else with this problem, but the post referenced above is fairly easily understood.
http://www.concrete5.org/community/forums/usage/flash-galleries-xml...
When I changed my code to the following the images began appearing:
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addParam("base", "themes/vsm/as3/");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
The line beginning with so.addParam("base"... did the trick. I wish I could add some more useful information to help out anyone else with this problem, but the post referenced above is fairly easily understood.
Hey Chad, I was adding the same js file to another page, and I had forgotten that I had used your script to add the file to the header. After awhile I remembered... duh. I just wanted to say thanks again for the add on.
I am really running this into the ground, but I am still having trouble, so please bear with me.
I have the flash settings working properly and it works properly when I use Chad's add script block. I would really like to put this directly into the template so I don't have to manage a block on every page of the website.
This is a flash image scroller. I have added this code to the header.php file between the <head> and </head> tags:
When I view a page I see a white box where the images should be appearing. Can anyone help me troubleshoot this? Thanks.
I have the flash settings working properly and it works properly when I use Chad's add script block. I would really like to put this directly into the template so I don't have to manage a block on every page of the website.
This is a flash image scroller. I have added this code to the header.php file between the <head> and </head> tags:
<script type="text/javascript" src="<?=$this->getThemePath()?>/as3/swfobject.js"></script>
When I view a page I see a white box where the images should be appearing. Can anyone help me troubleshoot this? Thanks.
that is because your not on the home page,
on the homepage it looks for the xml at url.com/whaver/some.xml
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addParam("base", "<?=$this->getThemePath()?>/as3/");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
on the homepage it looks for the xml at url.com/whaver/some.xml
<div id="flashcontent">
<script type="text/javascript">
var so = new SWFObject("themes/vsm/as3/banner.swf", "mymovie", "383", "256", "9");
so.addParam("menu", "false");
so.addParam("base", "<?=$this->getThemePath()?>/as3/");
so.addVariable("dataPath", "banner_asset/data.xml");
so.write("flashcontent");
</script>
</div>
If these concrete5 guys are serious about making money, they should put a donate now button for each user so when you post an answer that solves a frustrating problem (like you just did!) I could easily reward you for helping.
Enough gushing. I tried your change but still got the blank white space. But as I was looking at what you did, I realized the "var so = new..." line also had a hardcoded location. Being the critical thinker that I am, I said to myself, "that line should have the php helper also!" So I added it and bam! Everything is working swell.
The final block should be:
I know some css, html, python, but no .js or .php so some of these things are difficult for me. Thank you so much for the help.
Enough gushing. I tried your change but still got the blank white space. But as I was looking at what you did, I realized the "var so = new..." line also had a hardcoded location. Being the critical thinker that I am, I said to myself, "that line should have the php helper also!" So I added it and bam! Everything is working swell.
The final block should be:
<div id="flashcontent"> <script type="text/javascript"> var so = new SWFObject("<?=$this->getThemePath()?>/as3/banner.swf", "mymovie", "383", "256", "9"); so.addParam("menu", "false"); so.addParam("base", "<?=$this->getThemePath()?>/as3/"); so.addVariable("dataPath", "banner_asset/data.xml"); so.write("flashcontent"); </script> </div>
I know some css, html, python, but no .js or .php so some of these things are difficult for me. Thank you so much for the help.
<script type="text/javsacript" src="myjavascript.js"></script>
do:
<script type="text/javascript" src="<?=$this->getThemePath()?>/elements/myjavascript.js"></script>