Search for a solution to check a URL and derive a logic condition from it - SOLVED

I’m looking for a stacks solution to do the following.

On web page load, a stack to check a URL such as https://website.com/offers.pdf to see if this file exists. If the file exists then do thing 1, and if the file doesn’t exist, then do thing 2. Things 1 & 2 would be stacks areas to add stacks content.

Typical example applications for this would be to display current offers on a web site if the file offers.pdf is loaded to the server, or display Xmas Menu download button to download xmas_menu.pdf, if the file xmas_menu.pdf, is present on the server. There are many such applications where a business owner could add promotions, updates, etc, by creating a pdf (or other file) and loading to their server.

I am aware that this can be done with a full CMS solution, but such a stacks solution could be a much lighter and quick to implement solution. I would see this type of solution being just 1 stack, requiring 1 URL to be input and then the stacks content to be added as required.

Does anyone know of such a solution?

Would you be checking an external website (hosted on a different domain)? Or checking the presence of a file stored on the same domain the page is being viewed on?

If the latter, then this would be quite simple to do with PHP. I would cURL the target file, return its status, then have if / else if conditions to determine what content to display.

Quite simple to code (if you know PHP) but I know of no existing stacks that can do this.

Bryn Owen’s MultiSwitch stack would be a possibility. Though you would need to use your own code to see if the file is present and assign that result to a php variable.

@willwood The check would be on the same domain. Encouraging that you make sound not too difficult if you know php. If you’re looking for an idea for a new stack …

To develop the idea a bit further, if you could check for the presence of a file such as a txt text file, and then insert the file content text into text stacks with the class set to the name of a text file, this could be a powerful system.

In this example, adding a file called introduction.txt with the contents “Hello”, could be used to display Hello in a normally hidden paragraph or header with the class of introduction.

If you want to email or DM me the details, I’ll take a look at this tomorrow. I have a couple of hours to burn, so could try to get something working for you then.

1 Like

Hi Will,

I have sent you a DM.

The use case for this type of stack is for people who are happier using FTP Apps instead of CMS solutions that require knowing where the CMS login is, what the password is and then some knowledge of how to use the CMS. Over the years I have found that some small businesses give this type of CMS update task to those who come and go in the business and there is a new learning curve required when they infrequently want to update their web site with a new menu for download, or voucher code, or sale promotion. These type of clients are often very happy to create printed material and then sellotape to their restaurant door, window, bar wall, etc…

All that is needed for the client is an FTP app setup on their desktop with the settings for the document folder stored. The client or web designer or marketing people can then drag the required files into the folder and remove when the promotion is over.

Will has pulled a rabbit out of the hat here and come up with a perfect solution that is simple to use and works. I can see a lot of use for this.

Implementing this is several sites I have, will save me probably 30 minutes per site, as I can just drag a new menu or offers or vouchers file into a clients site and then delete it when the offer has expired. The means that I would no longer have to fire up RW, to add the new download menu or offers or vouchers download button, add the files and then up repeat this process again to remove the offer.

Also Will was kind enough to suggest I share it with anyone who’s interested wile he creates a product page for it. DM me if you are interested.

Will has now released the solution which is dropCMS - https://stacks4stacks.com/dropcms/ .

Check it out as it is a really powerful solution that will provide what many would otherwise be directed to use a full over the top CMS solution.

2 Likes