pamela1991 — 2012-06-20T15:23:57-04:00 — #1
I will be making a slideshow, and although I was already aware that it can be done via PHP, I recently discovered that it can also be done with CSS.
Initially, I was planning to do the slideshow in PHP, but now that I know it can also be done in CSS, I'm confused as to which route I should take.
As I've recently entered the world of CSS, when I realized the slideshow can be done in CSS, this made me want to do the slideshow in CSS--mainly because I'm intrigued by CSS and am just finding CSS to have so many delightful surprises.
However, upon further thought, I questioned myself as to whether or not it would actually be better to stick to PHP rather than CSS for the slideshow. The main reason I am thinking that PHP would actually be preferable in this regard is because in PHP, I will not have to worry about browser compatibility or display issues (unless I'm mistaken about this).
I do not know if this reason is valid enough, or whether it is in fact better to do the slideshow in PHP opposed to CSS.
I'd really appreciate hearing the advice that anyone here has to offer on this: would it be preferable to do a slideshow in CSS or PHP?
ralphm — 2012-06-20T18:48:35-04:00 — #2
PHP and CSS are not alternatives to each other. PHP happens on your web server, and CSS happens in your web browser. So your browser doesn't know anything about what happens in PHP. As far as it is concerned, you just send it some images and some CSS styles for presenting those images on the page. If you don't use CSS, the page will be completely plain.
Perhaps let us know what kind of slideshow you want and we can make suggestions.
dresden_phoenix — 2012-06-20T20:46:15-04:00 — #3
This is a case of hammering with a screwdriver.
PHP can write the mark up, and I suppose output the CSS for a slide show, but PHP itself doesn't make the sideshow.
As ralph said you can style your mark up ( which will probably be a UL, OL, or series of nested DIVs) with CSS or js to get the desired slide show effect. And while using CSS3 may cut down on crossbrowser friendliness, it may eliminate the need for js for those "complex" effects.
Technically speaking, you could do a sideshow in pure HTML ( static) and CSS3 with no .js IF you hand coded all the content, as opposed to having PHP build and serve it as needed. This would SUCK for slow bandwidth, tho.
ralphm — 2012-06-20T21:30:29-04:00 — #4
This is a cool slider powered by JS, but which also slides thanks to CSS3 if JS is off:
(The CSS3 version won't work in all browsers, though.)
technobear — 2012-06-21T10:27:47-04:00 — #5
That's really nifty - except it doesn't have a pause button. Am I just not looking carefully enough?
pamela1991 — 2012-06-21T13:00:43-04:00 — #6
Thanks for the helpful information, Ralph and Ray!
This slideshow will be a very simple slideshow with each image simply fading/dissolving into the next one after a constant specified duration. Each image would be a link as well. It would be nice to have the slideshow pause at the current slide upon hover over, but not essential as long as I'm able to have forward/backward arrows.
That is a cool slider! Thanks, I've bookmarked it as I'm quite certain it will come in handy for different future projects.
As a side question, since PHP is still in the air here, for things that you can do in either HTML or PHP, is it preferable to use HTML in such cases instead of PHP? And if so, would this reason be because using HTML rather than PHP would be faster for the visitor as they won't have to wait for processing from the server, as well as being easier on the server? An example of what I mean is:
<?php echo "Hello world"; ?>
ralphm — 2012-06-21T18:36:00-04:00 — #7
An unfortunate limitation indeed. So the search for the perfect slider goes on ... (if there is such a thing, as I'm not too keen on sliders at the bet of time).
No, it's a very healthy mentality.
The important thing to consider is what happens if JS is off. If the content is still accessible, then it's fine, IMHO. For example, imagine a gallery of thumbnails that expand and hover over the page when clicked. With JS off, the thumbnails should still appear, and when you click on you get taken to the enlarged version on a separate page. Perfectly acceptable.
Likewise, if you have images in a slider, with JS off you should at least be able to manually scroll sideways to see the other images. (This can often easily be set up via CSS if the slider code doesn't come with this feature.)
for things that you can do in either HTML or PHP, is it preferable to use HTML in such cases instead of PHP? And if so, would this reason be because using HTML rather than PHP would be faster for the visitor as they won't have to wait for processing from the server, as well as being easier on the server?
In my experience, PHP is very fast, so I don't see a problem in using it ... as long as it's not over used. The hello world example probably is overkill. I mainly use PHP for "includes", where common information like the HTML for your header, footer and menu is stored in one place and pulled onto each page. Then you can modify them in one place and not have to update each page.
dr_john — 2012-06-22T15:48:40-04:00 — #8
You use php to write the html of a web page. Often from a database interaction.
So apart from includes giving you a bit of re-usable, edit once use many times, code, you need a reason to use php to write the html. PHP isn't a substitute for html. It's an extra step in creating the html. In the case of a database driven site, it's a must. But for an ordinary web site it is usually an extra step.