Jump to content

Using Javascript within a PHP framework (Omeka)


redgreen99

Recommended Posts

(Cross-posted to Javascript area)

I am using a PHP CMS much like Drupal (it's called Omeka). I'd like to include an image carousel on my pages, and have only found Javascript that does this (no PHP, which would make things easier). I've read that I can include the Javascript in my php file by echoing the script something like below, but that is not working. Any help you can would be appreciated (as well as any PHP image gallery carousels you might have seen!). Thank you!

 

This is the actual Javascrip I wish to include:

<script type="text/javascript" src="javascripts/compressed.js"></script>
<script type="text/javascript">
$('slideshow').style.display='none';
$('wrapper').style.display='block';
var slideshow=new TINY.slideshow("slideshow");
window.onload=function(){
	slideshow.auto=true;
	slideshow.speed=8;
	slideshow.link="linkhover";
	slideshow.info="information";
	slideshow.thumbs="slider";
	slideshow.left="slideleft";
	slideshow.right="slideright";
	slideshow.scrollSpeed=4;
	slideshow.spacing=5;
	slideshow.active="#fff";
	slideshow.init("slideshow","image","imgprev","imgnext","imglink");
}
</script>

 

This is how I tried to work it into the PHP (but it doesn't work):

<?
echo "<script type=\"text/javascript\" src=\"javascripts/compressed.js\"></script> \n";
echo "<script type=\"text/javascript\"> \n";
echo "$('slideshow').style.display='none'; \n";
echo "$('wrapper').style.display='block'; \n";
echo "var slideshow=new TINY.slideshow(\"slideshow\"); \n";
echo "window.onload=function(){ \n";
echo "slideshow.auto=true; \n";
echo "slideshow.speed=8; \n";
echo "slideshow.link=\"linkhover\"; \n";
echo "slideshow.info=\"information\"; \n";
echo "slideshow.thumbs=\"slider\"; \n";
echo "slideshow.left=\"slideleft\"; \n";
echo "slideshow.right=\"slideright\"; \n";
echo "slideshow.scrollSpeed=4; \n";
echo "slideshow.spacing=5; \n";
echo "slideshow.active=\"#fff\"; \n";
echo "slideshow.init(\"slideshow\",\"image\",\"imgprev\",\"imgnext\",\"imglink\"); \n";
echo "}\n";
echo "</script>";
?> 

Link to comment
Share on other sites

  • 2 weeks later...

Things in "" will be executed in some way. Explained in code:

<?php
$var1 = "test";
$var2 = $var1;   // Results in $var2 being equal to "test"
$var3 = "$var1"; // Results in $var3 being equal to "test"

Therefor you code will give a warning, since you're trying to access the variable called $('slideshow'). A variable in PHP may only consist of letters, numbers and underscore, where the first letter may only be a letter or an underscore. But as pointed out previously in this thread, why even bother writing it in PHP?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.