Installing a Script

When you use a content management system like WordPress, Drupal or Joomla, or, if you use a web service like Wix, Weebly or Shopify, they offer a large library of additional software you can add to your site for functions like forms, galleries and sliders. But what do you do if you have created a static site or even a simple PHP site from straight code? Do you have to write those functions yourself? No, there are many scripts that you can install that will provide those functions for you!

For this article, we will use Folio Gallery as an example of how to find and install a PHP script.

Finding a Free Script

The first thing is to find a script. I did a Google search for “php gallery script free“. There were a number of scripts available, but I decided to try out Folio Gallery because it doesn’t require database set up.

Installing the Free Script
  1. I downloaded the script and unzipped it. It has an ugly folder name: foliogallery-master-3.5.1
  2. The directions say that the folder has to be at the root level of my website. I uploaded it using WinSCP.
  3. What happens if I try to run the gallery by using the folder name: https://montanawebmaster.com/foliogallery-master-3.5.1/? I get a 403 error, which means that the server sees the folder, but doesn’t know which file in the folder to load. And, that is because the script folder does not contain an index file.
  4. Testing the script: I want to test the script before I any changes. That is, I want to see what it does in a browser. In every folder on a website, there is one file that is the starting place. In this script, the instructions aren’t very clear. I took a guess that the main file in the folder is foliogallery.php and gave that a try. Sure enough it runs a slide show with photos that came with the zip file. The main address goes to a list of the “albums, where each album has a thumbnail and a caption. The thumbnails link to a page with a strip of thumbnails and captions for the individual album. And each image links to a full size image.
  5. Adding my own images: The instructions do say that I can add my own photos to the albums folder. So, added a folder in albums that has the screenshots for this post. When I open the main gallery page in the browser, my new gallery is listed in text, but there is no thumbnail.
    Note: Because there is no thumbnail, there is no link. That is a UX problem. Both the thumbnail and the caption should be linked.
  6. Creating the thumbnails: If you are used to a CMS, like WordPress, thumbnails are created when the images are added to the Media Library. Again, the instructions for this script are minimal and don’t mention thumbnails beyond saying that it can create thumbnails for you: “Automatic thumbnail creation.”. Back in the old days, we always made our own thumbnails because software wasn’t as robust as it is now.
Debugging the Script

The script didn’t create thumbnails when I looked at the page, but the description on the script website says that it does create thumbnails. The other gallery folders have a subfolder called thumbs, but my gallery folder doesn’t. That means that uploading the files doesn’t trigger thumbnail creation. It also means that either loading the galleries in the browser doesn’t trigger thumbnail creation or something is wrong and needs to be debugged.

A look through the code will give us some clues.

Since this software is a script, as opposed to compiled software, we get to see all the code. And, since we can see the code we can debug the code. Of course, one way to handle the problem would be to ask about the thumbnails on their comments section, but then we would not get the fun of debugging the script.

There are a number of tools for debugging code, but one easy way to do your debugging is to add statements that show on the screen at various places in the script to find where the error is.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *