Harry Muhren Posted December 31, 2019 Share Posted December 31, 2019 I have looked at your manual and automatic slider ‘how to examples’, in which the img src paths are set for each media library image separately - with their absolute paths. I have written a php snippet in which the urls of a number of the most recent uploaded images are determined. I can’t find out how this snippet can be combined with the html (css and javascript) code. Could you please provide a suggestion how to tackle this, using the php code or another way of getting the most recent uploaded media library images in a slider, without the need to set the absolute paths individually. Thanks - Harry Link to comment Share on other sites More sharing options...
dsonesuk Posted December 31, 2019 Share Posted December 31, 2019 They have to be set individually? Save them to php array then within slideshow loop through filepaths/filenames and add to newly created img element src attribute. Link to comment Share on other sites More sharing options...
Harry Muhren Posted January 1, 2020 Author Share Posted January 1, 2020 Thanks dsonesuk! In my php code snippet, indeed, I save the urls in a php array. The problem, however, is how to integrate this in de html code in for instance the examples given in the ‘how to’ html code of a slider. Maybe you can give me a piece of example code. Thanks in advance- regards - Harry Link to comment Share on other sites More sharing options...
dsonesuk Posted January 1, 2020 Share Posted January 1, 2020 (edited) Its not that hard? Learn how loop through each array item, with for instance a foreach loop, echo out each item in array, once you have that, then add string content that will be the html up to img src=" then learn to add php loop array value between quotes of src attribute. https://www.w3schools.com/php/php_looping_foreach.asp Edited January 1, 2020 by dsonesuk Link to comment Share on other sites More sharing options...
Harry Muhren Posted January 6, 2020 Author Share Posted January 6, 2020 Dear dsonesuk, The php function code by itself is no problem, but how to combine that with html, css and javascript. I have attached the slider code, with three lines of php code, which I have tried to run on the w3schools website in the 'how to' section, but without succes. Obviously, the php is ignored. Perhaps yo can provide a last hint!? By the way, can you tell how I can change my display name? Thanks - regards - Harry slider.txt Link to comment Share on other sites More sharing options...
dsonesuk Posted January 6, 2020 Share Posted January 6, 2020 All you have to do is produce on each loop <div class="mySlides fade"> <div class="numbertext">1 / 3</div> <img src="img_nature_wide.jpg" style="width:100%"> <div class="text">Caption Text</div> </div> With text in red as the stored item value in php array. echo '<div class="mySlides fade">'; echo '<div class="numbertext">1 / 3</div>'; echo '<img src="'.$img_in_array.'" style="width:100%">'; echo '<div class="text">Caption Text</div>'; echo' </div>'; then do the same with <span class="dot" onclick="currentSlide(1)"></span> using a counter to reproduce individual dots for each image to total of items in array Link to comment Share on other sites More sharing options...
Harry Muhren Posted January 6, 2020 Author Share Posted January 6, 2020 OK, but where to put the php code that provides the array? Link to comment Share on other sites More sharing options...
dsonesuk Posted January 6, 2020 Share Posted January 6, 2020 Anywhere before it is referenced Link to comment Share on other sites More sharing options...
Harry Muhren Posted January 6, 2020 Author Share Posted January 6, 2020 I understand, but I have tested that with a simple php code (in the attached file), just saying 'hello', but obviously the compiler does not interpret it. But nevertheless, I do not want to bother you any longer. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now