I would like to understand how this works.
The jQuery carousel I would like to use is Elastislide.
http://tympanus.net/codrops/2011/09/12/elastislide-responsive-carousel/
The site gives us the code we need to use :
var carousel = $('#carousel').elastislide();
...
$('#carousel').append("<li><a href="#"><img src="images/10.jpg" alt="image03" /></a></li>");
carousel.add();
I also found those lines in the jquery.elastislide.js file but it's being ignored by /*
This is the HTML :
<div>
<div class="fixed-bar">
<!-- Elastislide Carousel -->
<ul id="carousel" class="elastislide-list">
<li><a href="http://www.site1.com"><img src="images/1.jpg" alt="img1" /></a></li>
<li><a href="http://www.site2.com"><img src="images/2.jpg" alt="img2" /></a></li>
<li><a href="http://www.site3.com"><img src="images/3.jpg" alt="img3" /></a></li>
<li><a href="http://www.site4.com"><img src="images/4.jpg" alt="img4" /></a></li>
</ul>
<!-- End Elastislide Carousel -->
</div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquerypp.custom.js"></script>
<script type="text/javascript" src="js/jquery.elastislide.js"></script>
<script type="text/javascript">
$( '#carousel' ).elastislide( {
minItems : 1
} );
</script>
The HTML obviously looks for all those items. But it's the javascript that decides what gets shown in the html, based on what's available, right ?
So my guess is the html needs to look like this before I do anything with it :
<!-- Elastislide Carousel -->
<ul id="carousel" class="elastislide-list">
</ul>
<!-- End Elastislide Carousel -->
And I need to add Javascript to it.
Otherwise how is it going to add list items like images and links ?
Can someone confirm this is correct ?
I don't think I'm done after that, I will need to add the path somewhere, probably in the javascript as well.
Otherwise how will it know in what folder it needs to look ?
To make matters more complicated (or maybe not), I'm trying to do this in Joomla.
I could install extensions that more or less do something similar than this carousel but I don't want to because all that comes down to is clicking buttons without really understanding it.
Thank you.
Here is the full working static HTML page with Elastislide carousel to start with
Notice that file structure is important - for such HTML you must have:
/ filanme.htm (or .php) - the page itself
/ css/* - css files included
/ js/* - javascripts included
/ images/* - Elastislide supplementary images (contained in its package)
To generate such a page with PHP hypertext preprocessor your steps could be like these.
Retrieve PHP data from Joomla CMS (or MySQL database directly) about which images and links site administrator wish to be loaded into the carousel. It's hard for me to say how to do this with Joomla, because I do not use it very often, so I would give an example of simple function, always returning 'precooked' PHP array with data.
After you got data, generate markup of
ul
andli
s that forms carousel source and insert script with$('#carousel').elastislide();
call after it.Here is simplistic, but working PHP code sample:
To get this really working you should place the code above in .php file on your site, place other required files to appropriate folders and, of course, find real API in Joomla CMS to retrieve data for carousel and and make use of it.