FreewayTalk

35 replies to this thread. Most Recent

Zignar

21 Dec 2018, 9:34 am

Seasonal gallery on responsive site

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 </head> picker from the bottom of that dialog, and entering the following line of code:

<link rel="stylesheet" type="text/css" href="Resources/seasonal.php" />

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');
?>
#seasonal_picture {

background-image: url(Resources/<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

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: http://actionsforge.com/actions/upload-extra-resources 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?

Thanx Sverker

http://www.smalandsgardar.nu/aktuellt.php

waltd

21 Dec 2018, 2:27 pm

For a start, you have included the stylesheet in your page before all html, not at the “Before </head>” section. Also, ensure that you have uploaded the seasonal.php file to your Resources folder (using an Action or just an SFTP application). It is currently not there. Once you get those two things taken care of, the final bit that I think I messed up in my first pass at this is that the URLs to the individual images in the generated stylesheet need to lose the Resource/ prefix part. Stylesheets reference the URLs they contain relative to the stylesheet itself, not the page that links to it, so the relative URL to these images (also uploaded to the Resources folder) would just begin with the filename, not the path part.

Walter

On Dec 21, 2018, at 4:34 AM, Zignar <[email protected]> wrote:

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 </head> picker from the bottom of that dialog, and entering the following line of code:

<link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

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'); > ?>

seasonal_picture {

background-image: url(Resources/<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

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: http://actionsforge.com/actions/upload-extra-resources 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?

Thanx Sverker

http://www.smalandsgardar.nu/aktuellt.php

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

21 Dec 2018, 3:53 pm

Thanks for getting back to me so quickly.

Strange that the seasonal.php does not list in the resources. I uploaded it with Transmit. It is still there when I view the folder!?

I am not sure if you understand your instructions correctly. I tried and edited the HTML markup <link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

It now reads <link rel=”stylesheet” type=”text/css” href=”seasonal.php” /> and I moved it to it’s correct position ( Before </head>).

I feel a bit stupid, but even more grateful for your help. Merry X-mas! S

waltd

21 Dec 2018, 4:08 pm

Sorry, the change I was mentioning needs to happen in the PHP file, not in the Freeway generated HTML. Did you upload the seasonal.php into the Resources folder, or in the same folder as the HTML file? If the former, it’s not found by my browser there.

Make the PHP code look like this:

<?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');
?>
    #seasonal_picture {
background-image: url(<?php print($images[date('n')); ?>);
background-size: cover;
background-position: center;
}

(removing the Resources/ part)

And then ensure that the link to seasonal.php includes the Resources/ part (in Freeway), and is in the before /head section. Finally, ensure that seasonal.php has been uploaded to the Resources folder.

Walter

On Dec 21, 2018, at 10:53 AM, Zignar <[email protected]> wrote:

Thanks for getting back to me so quickly.

Strange that the seasonal.php does not list in the resources. I uploaded it with Transmit. It is still there when I view the folder!?

I am not sure if you understand your instructions correctly. I tried and edited the HTML markup <link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

It now reads <link rel=”stylesheet” type=”text/css” href=”seasonal.php” /> and I moved it to it’s correct position ( Before </head>).

I feel a bit stupid, but even more grateful for your help. Merry X-mas! S

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

22 Dec 2018, 10:26 am

I tried it, but still nothing.

My actual seasonal.php reads as follows:

<?php
$images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg, 3 => 'winter3.jpeg',
                       4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg',
                       7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg',
                       10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg',
                       13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg',
                       16 => 'fall4.jpeg');
header('Content-type: text/css');
?>
#seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

It is (and has always been) uploaded (FTP) as follows: /public_html/Resources/seasonal.php

The page is responsive and also has WebYep CMS on it. Could that be a factor?

waltd

22 Dec 2018, 5:38 pm

The problem I see immediately is that your quotes are curled in the Link tag you entered in Freeway.

    <link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

should be:

    <link rel="stylesheet" type="text/css" href="Resources/seasonal.php" />

The difference is admittedly very subtle, but this is why we use Programmer’s Text Editors when programming.

Walter

On Dec 22, 2018, at 5:26 AM, Zignar <[email protected]> wrote:

I tried it, but still nothing.

My actual seasonal.php reads as follows:

<?php > $images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg, 3 => 'winter3.jpeg', > 4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg', > 7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg', > 10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg', > 13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg', > 16 => 'fall4.jpeg'); > header('Content-type: text/css'); > ?>

seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

It is (and has always been) uploaded (FTP) as follows: /public_html/Resources/seasonal.php

The page is responsive and also has WebYep CMS on it. Could that be a factor?

Freeway user since 1997

http://www.walterdavisstudio.com

waltd

22 Dec 2018, 6:36 pm

When I correct those problems in my browser, I get a 500 error from the seasonal.php script, which means that there’s a syntax error somewhere within it as well. Looking at the code you posted here in this thread, that’s because there’s a missing single-quote after winter2.jpeg.

Walter

On Dec 22, 2018, at 12:38 PM, Walter Lee Davis <[email protected]> wrote:

The problem I see immediately is that your quotes are curled in the Link tag you entered in Freeway.

<link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

should be:

<link rel="stylesheet" type="text/css" href="Resources/seasonal.php" />

The difference is admittedly very subtle, but this is why we use Programmer’s Text Editors when programming.

Walter

On Dec 22, 2018, at 5:26 AM, Zignar <[email protected]> wrote:

I tried it, but still nothing.

My actual seasonal.php reads as follows:

<?php >> $images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg, 3 => 'winter3.jpeg', >> 4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg', >> 7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg', >> 10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg', >> 13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg', >> 16 => 'fall4.jpeg'); >> header('Content-type: text/css'); >> ?>

seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

It is (and has always been) uploaded (FTP) as follows: /public_html/Resources/seasonal.php

The page is responsive and also has WebYep CMS on it. Could that be a factor?

Freeway user since 1997

http://www.walterdavisstudio.com

waltd

22 Dec 2018, 6:57 pm

Not to keep banging this drum, but I figured this out not by squinting at the code here in FreewayTalk, but by pasting it into a programmer’s text editor. I used TextMate 2, which is free at the moment (it’s been in beta for at least two years), but historically has cost €150, and worth every penny. https://macromates.com For free, you can use BBEdit from https://barebones.com in its “free forever” mode, which replaced their TextWrangler app a while back.

What any programmer’s editor will give you is syntax coloring, which shows you string values (like ‘winter1.jpeg’) in one color, while numbers are another color, and variable declarations like $images are yet another color. This makes it really easy to see where those kinds of mistakes are.

Here’s an example, rendered using GitHub’s Gist service:

See how the colors change in the example.php, compared with the example2.php?

Walter

On Dec 22, 2018, at 1:36 PM, Walter Lee Davis <[email protected]> wrote:

When I correct those problems in my browser, I get a 500 error from the seasonal.php script, which means that there’s a syntax error somewhere within it as well. Looking at the code you posted here in this thread, that’s because there’s a missing single-quote after winter2.jpeg.

Walter

On Dec 22, 2018, at 12:38 PM, Walter Lee Davis <[email protected]> wrote:

The problem I see immediately is that your quotes are curled in the Link tag you entered in Freeway.

<link rel=”stylesheet” type=”text/css” href=”Resources/seasonal.php” />

should be:

<link rel="stylesheet" type="text/css" href="Resources/seasonal.php" />

The difference is admittedly very subtle, but this is why we use Programmer’s Text Editors when programming.

Walter

On Dec 22, 2018, at 5:26 AM, Zignar <[email protected]> wrote:

I tried it, but still nothing.

My actual seasonal.php reads as follows:

<?php >>> $images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg, 3 => 'winter3.jpeg', >>> 4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg', >>> 7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg', >>> 10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg', >>> 13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg', >>> 16 => 'fall4.jpeg'); >>> header('Content-type: text/css'); >>> ?>

seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

It is (and has always been) uploaded (FTP) as follows: /public_html/Resources/seasonal.php

The page is responsive and also has WebYep CMS on it. Could that be a factor?

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

23 Dec 2018, 8:14 am

Thanks, all that is very helpful. I have been using TextWrangler for some time. Will check out the others.

I have updated both the page link and the php files but still nothing…

Could image sizes or frame sizes be an issue?

Merry Christmas! S

waltd

23 Dec 2018, 5:22 pm

You still have a PHP error in your seasonal.php script. It’s there, almost where it’s supposed to be, but coming back with a 500 error. Check to make sure you uploaded seasonal.php again after adding the single-quote where I indicated.

Things to do, in order, to see how this can be fixed.

  1. In Freeway, move the link to seasonal.php from the Before <head> section to the Before </head> section. That forward-slash is important here.
  2. In the seasonal.php file, at the top of the script, right after the first line (<?php), add these two lines to turn on full debugging:
error_reporting(E_ALL);
ini_set('display_errors',1);

This should let the server tell you why it’s not working as written.

In order to view the errors, visit this URL:

http://www.smalandsgardar.nu/Resources/seasonal.php

…in a browser. You should see all of the issues spelled out for you there.

Once you see what those issues are, and correct them, you can then remove or comment out* those two lines. It’s always best to run in production with debugging off, because failing silently doesn’t give away details about your server that you don’t want others to know.

Walter

*To comment out a line of code (inside the <?php ... ?> delimiters) add two slashes at the beginning of the line.

On Dec 23, 2018, at 3:14 AM, Zignar <[email protected]> wrote:

Thanks, all that is very helpful. I have been using TextWrangler for some time. Will check out the others.

I have updated both the page link and the php files but still nothing…

Could image sizes or frame sizes be an issue?

Merry Christmas! S

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

24 Dec 2018, 10:09 am

There is a mystery…

I have opened my http://www.smalandsgardar.nu/Resources/seasonal.php with TextMate. I have copied the content and it reads as follows:

<?php
$images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg', 3 => 'winter3.jpeg',
                       4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg',
                       7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg',
                       10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg',
                       13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg',
                       16 => 'fall4.jpeg');
header('Content-type: text/css');
?>
#seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

Is this different from what you find? If so, where is the error?

waltd

24 Dec 2018, 2:09 pm

This looks okay, but clearly, your server isn’t having anything to do with it. You need to add the two lines that turn on visible debugging output, and see what the actual problem is by visiting it in a browser. Then you can see for yourself what the issue is. Note that the output may be meaningless to you: there is a substantial “learning cliff” to figuring out what ails a server. If you either leave this in debugging mode, or copy and paste the output here and turn debugging back off for your own peace of mind, I will probably be able to figure it out from the message. But then, I’ve been doing this for over 20 years.

Walter

On Dec 24, 2018, at 5:09 AM, Zignar <[email protected]> wrote:

There is a mystery…

I have opened my http://www.smalandsgardar.nu/Resources/seasonal.php with TextMate. I have copied the content and it reads as follows:

<?php > $images = array(1 => 'winter1.jpeg', 2 => 'winter2.jpeg', 3 => 'winter3.jpeg', > 4 => 'winter4.jpeg', 5 => 'spring1.jpeg', 6 => 'spring2.jpeg', > 7 => 'spring3.jpeg', 8 => 'spring4.jpeg', 9 => 'summer1.jpeg', > 10 => 'summer2.jpeg', 11 => 'summer3.jpeg', 12 => 'summer4.jpeg', > 13 => 'fall1.jpeg', 14 => 'fall2.jpeg', 15 => 'fall3.jpeg', > 16 => 'fall4.jpeg'); > header('Content-type: text/css'); > ?>

seasonalpicture {

background-image: url(<?php print($images[date('n')); ?>); background-size: cover; background-position: center; }

Is this different from what you find? If so, where is the error?

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

25 Dec 2018, 10:52 am

I tried that but nothing at all displayed, either in Safari or in Firefox. Do I need to turn something else on in the browser?

Zignar

25 Dec 2018, 12:10 pm

I turn on JavaScript konsol and get some errors, but neither make sense to me:

  1. Failed to lead resource: the server responded with a status of 500 (internal server error)

When I click the displayed link to the file on the right (http;//www.smalandsgardar.nu/Resources/seasonal.php I get a second error message:

  1. Recourse is empty (my translation from Swedish).

Any idea? (I turn of the debug again) S

waltd

26 Dec 2018, 6:14 pm

I ran this on my Mac, and the error is in line 11, where there is a missing ] square bracket.

bad:

background-image: url(<?php print($images[date('n')); ?>);

good:

background-image: url(<?php print($images[date('n')]); ?>);

Fix that, and you should be good. I hadn’t anticipated that the error message would be localized.

You can run PHP scripts on a Mac using the Terminal.app, just navigate in Terminal (using cd) to the spot where the script is saved:

marvin:~ waltd$ cd Desktop/
marvin:Desktop waltd$ php seasonal.php
PHP Parse error:  syntax error, unexpected ')', expecting ']' in /Volumes/eddy/Users/waltd/Desktop/seasonal.php on line 11

Walter

On Dec 25, 2018, at 7:10 AM, Zignar <[email protected]> wrote:

I turn on JavaScript konsol and get some errors, but neither make sense to me:

  1. Failed to lead resource: the server responded with a status of 500 (internal server error)

When I click the displayed link to the file on the right (http;//www.smalandsgardar.nu/Resources/seasonal.php I get a second error message:

  1. Recourse is empty (my translation from Swedish).

Any idea? (I turn of the debug again) S

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

27 Dec 2018, 10:05 am

Super, that was it. Now the image displays, which generates two more questions:

  1. It is a responsive side, on all the pages I have an image wrapper with a image container and the image itself, (pass-through graphic set to 100% width and flexible hight). However, it does not work on this page. I now set the hight to minimum 100px and part of the image displays. How can I show the whole image, and yet retain the responsiveness as on the other pages?

  2. How and when do the images change? I notice that now image nr 12 is showing. (Month 12? In that case I would know how to order them easily)

Thank you so much for super help!!

waltd

27 Dec 2018, 2:26 pm

On Dec 27, 2018, at 5:05 AM, Zignar <[email protected]> wrote:

Super, that was it. Now the image displays, which generates two more questions:

  1. It is a responsive side, on all the pages I have an image wrapper with a image container and the image itself, (pass-through graphic set to 100% width and flexible hight). However, it does not work on this page. I now set the hight to minimum 100px and part of the image displays. How can I show the whole image, and yet retain the responsiveness as on the other pages?

A background image cannot influence the height or width of an object it is applied to, so you’ll have to use a different trick to make your image appear to flex like you want. One of the best tricks for this is to work out the percentage difference between the width and the height (the aspect ratio) and then apply that to the padding-bottom of the box, leaving the height at 0 or unspecified. Let’s say your image had a 4:3 ratio, like an old TV. To get that in a flexible image, you would use the following CSS:

.tv {
    width: 100%;
    height: 0;
    padding-bottom: 75%;
}

If you also gave that a color, you’d see that it flexes to show the appropriate height for any given width (depending on the surrounding elements and viewport). If you applied your image to it as the background, using the background-size: cover and background-position: center attributes that I mentioned earlier, you’d see that the otherwise empty box would flex to match the image (even though the background image isn’t what is actually driving that sizing).

http://scripty.walterdavisstudio.com/tv.html

  1. How and when do the images change? I notice that now image nr 12 is showing. (Month 12? In that case I would know how to order them easily)

You got it. The months are converted to the numbers 1 .. 12, and that becomes the index of the array holding the image names. Which one shows is down to the values you add to the $images array.

Thank you so much for super help!!

You’re welcome, even for the typos. Now you know something about debugging, too, which is a foundation skill for any sort of programming.

Walter

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

27 Dec 2018, 4:24 pm

Everything works great now!!

Thanks for your patient support. Very, very helpful. I am almost inspired to go back to doing everything in FW again, now that I know it can be done!

Thanx

Zignar

27 Dec 2018, 5:46 pm

Ooops!! Stopped working again!!! What did I do??

waltd

27 Dec 2018, 5:59 pm

It looks like you’re missing the file

http://www.smalandsgardar.nu/Resources/winter1.jpeg

When you put that back, the page will look correct again.

You can see all of this, by the way, by turning on the Develop menu in Safari (in Preferences) and then choosing Develop / Show Web Inspector.

Walter

On Dec 27, 2018, at 12:46 PM, Zignar <[email protected]> wrote:

Ooops!! Stopped working again!!! What did I do??

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

27 Dec 2018, 6:27 pm

This is odd… I did change to higher resolution images. Everything is there… I closed FW, started again, verified files on the page, published everything again and uploaded and yet it is still not there!! How is this possible?

I finally used Transmit (ftp) to upload the image and everything is fine again!

I feels like the whole Apple environment is becoming more and more like Windows.

waltd

27 Dec 2018, 6:40 pm

Click on the image in Freeway, and look in the Inspector. Freeway may have renamed the file for you.

Walter

On Dec 27, 2018, at 1:27 PM, Zignar <[email protected]> wrote:

This is odd… I did change to higher resolution images. Everything is there… I closed FW, started again, verified files on the page, published everything again and uploaded and yet it is still not there!! How is this possible?

I finally used Transmit (ftp) to upload the image and everything is fine again!

I feels like the whole Apple environment is becoming more and more like Windows.

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

27 Dec 2018, 6:56 pm

Did that but no, that was not the reason. It was there, it just did not upload!!

Zignar

16 Jan 2019, 10:45 am

Something is still going on. I though we had fixed this. I looked great last month. I just checked the site and it should have switched image (jan 1) on this page: http://www.smalandsgardar.nu/aktuellt.php

However - now there is nothing!

Do you have any clue? Thank you!

Sverker

max

16 Jan 2019, 1:45 pm

the: winter2.jpeg image can’t be found in the Resource folder this the actual error:

        Failed to load resource: the server responded with a status of 404 (Not Found)  <http://www.smalandsgardar.nu/Resources/winter2.jpeg>

so my guess is its not there or not in the correct folder

Max

it’s better to be lucky than clever.. :o)

Zignar

16 Jan 2019, 4:18 pm

I am going nuts! They were all there, it seamed to be working fine, but now I notice that they have all been renamed by Freeway… very frustrating. Why does it do that?

I guess I should rewrite the PHP script rather than renaming the files. Otherwise it is bound to return and haunt me again.

Thank you Max!

Zignar

16 Jan 2019, 4:37 pm

Actually, I still need help!

I see this problem that seems vaguely familiar. I think I had something similar a number of years ago. But I cannot recall how or why this happens, and what I can do to prevent it…

As I check the files in resources I find that Freeway has not only changed the names on these images. It has also made duplicates and added a “b version” of each file. So instead of having winter1.jpeg, winter2.jpeg, winter3.jpeg, spring1.jpeg, etc. (a total of 12 images, one for each month, which the script call on). I now have winter2a.jpeg, winter2b.jpeg, winter3a.jpeg, winter3b.jpeg, spring1a.jpeg, spring1a.jpeg.

As I said, I think I have seen Freeway do something similar in the past, (with external resources?) What can I do to make sure FW does not fiddle around with the file names?

Thank you!!

Gordon Low

16 Jan 2019, 5:04 pm

Try using the built-in Upload Stuff action which may help with the renaming issues. Failing that upload the files using an FTP app like Fetch or Cyberduck.

Gordon http://www.gordonlow.net/


On 16 Jan 2019, at 4:37 pm, Zignar <[email protected]> wrote:

Actually, I still need help!

I see this problem that seems vaguely familiar. I think I had something similar a number of years ago. But I cannot recall how or why this happens, and what I can do to prevent it…

As I check the files in resources I find that Freeway has not only changed the names on these images. It has also made duplicates and added a “b version” of each file. So instead of having winter1.jpeg, winter2.jpeg, winter3.jpeg, spring1.jpeg, etc. (a total of 12 images, one for each month, which the script call on). I now have winter2a.jpeg, winter2b.jpeg, winter3a.jpeg, winter3b.jpeg, spring1a.jpeg, spring1a.jpeg.

As I said, I think I have seen Freeway do something similar in the past, (with external resources?) What can I do to make sure FW does not fiddle around with the file names?

Thank you!!

Zignar

16 Jan 2019, 5:08 pm

Well, I uploaded the files with Transmit. Worked great (as Transmit always do).

The question is rather why does Freeway duplicate and rename the files after the upload? If I write a php script, does Freeway require me to upload it via an action?

I don’t understand!

Gordon Low

16 Jan 2019, 5:16 pm

I think the reason for the renaming is that Freeway is trying to be helpful. It knows about all of its own resources and can change names and references internally. However it doesn’t want to risk overwriting any other files which may exist and be needed so it renames them. It’s the same when you copy and paste an image within Freeway, it’ll append a number or letter to the end. To some extent you can take control of this by looking at the names used in the side bar of each page and rename them yourself.

I’m sure Walter and Jeremy will have a better and more correct explanation.

All the best

Gordon http://www.gordonlow.net/


On 16 Jan 2019, at 5:08 pm, Zignar <[email protected]> wrote:

Well, I uploaded the files with Transmit. Worked great (as Transmit always do).

The question is rather why does Freeway duplicate and rename the files after the upload? If I write a php script, does Freeway require me to upload it via an action?

I don’t understand!

Zignar

16 Jan 2019, 5:18 pm

Walter or Max or Jeremy?!

Any explanation? What can I do to prevent this?

Thanks Sverker

waltd

16 Jan 2019, 6:05 pm

When Freeway publishes, it consults the document’s database of published resources (both user-added and Action-generated), and ensures that there are no duplicates. Duplicate (binary-equal files) are relinked, so that only one of each is published.

Next, it compares the files it knows about (the ones in its document) with any existing files in your local site folder that it didn’t create. Because it cannot know what you meant by putting those files in the output folder where it is publishing, Freeway renames the files that it will publish, to avoid overwriting a file you may be attached to.

Finally, when you upload, Freeway only uploads the files it published from the current document. No matter what else you put in the site folder on your Mac, Freeway will not upload it.

All of this is how it is supposed to work. Occasionally, Freeway will go nuts and forget about a file it published two weeks ago or whenever. Once that connection is broken, Freeway cannot guess what to do, so it treats that file as if you manually put it in the site folder.

The short answer is just to delete all the files in your site folder on your Mac. This is completely safe, because Freeway will generate all the files over again when you publish or preview.

Then go through the document page by page, click on each image, and rename it in the Inspector. Now when you upload, you should get the original names.

If you notice that you aren’t allowed to name an image in a certain way, it may be that you are using an “illegal” character in the name, and Freeway is saving you from your mistake.

If you see that an image is stubbornly adding a number or letter to its name, that’s because there is a duplicate-named element (not necessarily an image) on the same page.

If you see (by inspecting the Resources folder) that you have picture.jpeg, picture1.jpeg, picture1a.jpeg, etc., then that’s because you have two or more images named “picture” somewhere in the entire site that are not the same exact image.

Walter

On Jan 16, 2019, at 10:18 AM, Zignar <[email protected]> wrote:

Walter or Max or Jeremy?!

Any explanation? What can I do to prevent this?

Thanks Sverker

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

16 Jan 2019, 6:33 pm

Thanks Walter, That is really helpful, as far as I understand it. I now remember seeing this phenomena before, how FW adds a new file extension every time I publish.

I read through what you wrote several times and still I am uncertain of how to proceed fixing it. Bare with me..

If you remember, (you helped me with this earlier), we wrote a script for displaying these images in a box. When I now look at the images as listed in Freeway, they are all correctly named (as I named them before). However on the server they have been renamed - twice!

So, how do I proceed? I don’t see the point in deleting the files on my Mac (as they are all correctly named in FW). I am simply too dense to understand fully.

My instinct would be to delete all those images on the remote server, rename the images in Freeway to something more unique i.e januaryimage.jpeg, februaryimage.jpeg etc. Rewrite the php script accordingly, upload it (with my FTP or should I let FW handle it?) and then kill a chicken, pray and publish. I am afraid I will have forgotten it all, if this reoccurs in a few months (next time I publish the site).

Would this method above be likely to fix it? Thanx again for your patient support.

Sverker

waltd

16 Jan 2019, 7:06 pm

Try deleting the files on your Mac first. That’s easier and more likely to give you the results you want. There is no harm in doing this. If it makes you nervous for any reason, just use the Document Setup dialogue to specify a new, different site folder, so you’ll keep the old one. Then double check your document for renamed files, then publish. When you upload, Freeway will overwrite files on the server. It will never overwrite files on your Mac.

Walter

On Jan 16, 2019, at 11:32 AM, Zignar <[email protected]> wrote:

Thanks Walter, That is really helpful, as far as I understand it. I now remember seeing this phenomena before, how FW adds a new file extension every time I publish.

I read through what you wrote several times and still I am uncertain of how to proceed fixing it. Bare with me..

If you remember, (you helped me with this earlier), we wrote a script for displaying these images in a box. When I now look at the images as listed in Freeway, they are all correctly named (as I named them before). However on the server they have been renamed - twice!

So, how do I proceed? I don’t see the point in deleting the files on my Mac (as they are all correctly named in FW). I am simply too dense to understand fully.

My instinct would be to delete all those images on the remote server, rename the images in Freeway to something more unique i.e januaryimage.jpeg, februaryimage.jpeg etc. Rewrite the php script accordingly, upload it (with my FTP or should I let FW handle it?) and then kill a chicken, pray and publish. I am afraid I will have forgotten it all, if this reoccurs in a few months (next time I publish the site).

Would this method above be likely to fix it? Thanx again for your patient support.

Sverker

Freeway user since 1997

http://www.walterdavisstudio.com

Zignar

17 Jan 2019, 9:08 am

I am going nuts!

I went through everything above (I think). I even renamed the image files. Deleted everything. Renamed the file links in the php script. Uploaded that one, and finally published. Everything looked fine!

But, when I just republished the site (while working on a reCaptcha update), Freeway had renamed all the image files, adding the number 1. So now the PHP script no longer works.

Either I misunderstood you Walter or I did something wrong! Is it not possible to have this function stable, and being able to update the site without loosing it?

How can I go about to prevent this from being repeated (I can of course now rename the image files and the script will work until the next time I publish)

thanx Sverker

Back to Top

Zignar

17 Jan 2019, 12:11 pm

I think I finally beat the machine.

I went through the site in detail (on Freeway) and found some “lost” image links and other php links (old reCaptcha etc). Once that was all cleared up I did what Walter suggested (above).

I deleted all the files in my site folder on my local computer, published everything. I then connected with my FTP (Transmit) and compared the two directories (local & remote). I proceeded to delete any funny files on the remote that had been generated in the past by FW. Then I finally uploaded the site and everything looks clean and nice!

Hopefully it will stay that way for a while…

Sverker