Hi there Walter and all you other geniuses!
I built a responsive website I in Freeway (in Swedish) that has a ”current news” page. There is a foto in the header http://www.smalandsgardar.nu/aktuellt.php
My question is if it is at all possible to have some kind of function that would change the photo automatically accordingly to calendar date? Ideally I would like to rotate image at least 4 times per year (with each season). Looks corny with winter image in the middle of summer on a current news page). The people that manage the site are not capable of editing the picture…I think.
Any suggestions would be very helpful
I have now tried the following method (thanks Walter):
Manually, in Freeway, draw an HTML box on the page where you want to see the picture. Don’t put any content in it or style it in any way. Make note of what name that box has in the Inspector’s Name field. If you leave it at the defaults, it will be item[some number]. You can change it using the Inspector to something reasonable like
seasonal_picture or whatever.
On that same page, use the Page / HTML Markup dialog to add a stylesheet reference to the head of the page. You’ll do this by picking the Before picker from the bottom of that dialog, and entering the following line of code:
Make a new blank page where you can cause Freeway to upload your rotating pictures. Just place four (or more) image boxes on the page large enough to cover the empty HTML box on the other page, and fill each one with a picture. Write down the filename of each image (again, found in the Inspector) so you can add it back into your program later. You may want to triple-check what the actual filename is by using Preview In Browser in Freeway to publish that page, then use your browser’s Developer Tools to view the page source, so you can see precisely what Freeway named that file. Usually, you can use the Inspector to figure this out, combining the Name/ID from the left-most tab with the Type from the third-from-the-left (output) tab.
Next, you need to write the seasonal.php program:<?php $images = array(1 => 'winter.jpeg', 2 => 'winter.jpeg, 3 => 'winter.jpeg', 4 => 'spring.jpeg', 5 => 'spring.jpeg', 6 => 'spring.jpeg', 7 => 'summer.jpeg', 8 => 'summer.jpeg', 9 => 'summer.jpeg', 10 => 'fall.jpeg', 11 => 'fall.jpeg', 12 => 'fall.jpeg'); header('Content-type: text/css'); ?>
background-image: url(Resources/<?php print($images[date('n')); ?>);
You need to use a programmer’s text editor for this last part, because normal word processors will try to do nice things like “curl” the quotation marks, which will break the program. Obviously, adjust the pictures to your seasons and your image names. There’s no way to avoid the duplication, because the date() method doesn’t have a symbol for “what quarter of the year is it?”. Ensure that the names of the files in the array, and the ID of the seasonal_picture box are properly named for the actual pictures and HTML box you created in your Freeway pages.
Finally, to get Freeway to upload that file to where we told it it was in the Page / HTML Markup, you will need to install the Upload Extra Resources Action: Upload Extra Resources - ActionsForge and use it to upload the seasonal.php file into your Resources folder.
Once you do this, and assuming your server is normal and processes PHP scripts such as this without issue, then you should be able to see the whole thing working on your server. Nothing at all will happen in Freeway or if you use Preview in Browser on your Mac. The HTML box will just be a blank area in those cases. On your server, if everything about this is exactly right, you will see the seasonal picture where that box is…
As feared, it is not working. I have poked around to the extent of my ability and I cannot find the error.
Any chance anyone out there could spot it? Christmas is the magic season isn’t it?
freewaytalk mailing list
Update your subscriptions at: