Posts by Graham

    Thank you from us and all my customers for developing Perch and saving us from WordPress development.

    Wishing you all the luck in the future, with whatever you both do next. It has been good to have known you and met you.

    For the last two Runway installs I've had issues getting cron to then run on my server setup (in order to schedule the backups to Amazon S3). I now know the cause, but I'm unsure if its specific to my server hosting setup. I also have a solution, so I have decided to publish the info here for others. If you have the same issue and solved it a different way, I'd love to hear.

    On a Runway install, the config.php contains the following code at the top ...

    1. <?php
    2.     switch($_SERVER['SERVER_NAME']) {
    3.         case '':
    4.             include(__DIR__.'/config.www-mysite-com.php');
    5.             break;
    6.         default:
    7.             include('config.production.php');
    8.             break;
    9.     }

    The file config.www-mysite-com.php contains the sitepath, schedule_secret and database settings. The file config.production.php contains nothing except for an opening <?php statement. This all works perfectly when using Runway with http or https because the variable of $_SERVER['SERVER_NAME'] has a value.

    When using cron to set up an hourly job, I use a statement like this ...

    1. /opt/cpanel/ea-php72/root/usr/bin/php /home/mysite/public_html/perch/core/scheduled/run.php xxxxxxxxxx

    The cron job runs ok but doesn't do anything. After digging around I see this error ...

    'PHP Parse error: syntax error, unexpected end of file in /home/mysite/public_html/perch/config/config.production.php on line 1'

    My hosting company tells me that the cause is that the variable of $_SERVER['SERVER_NAME'] doesn't have a value when the PHP statements are run in CLI (Command Line Interface). Therefore the 'switch' statement can't do the necessary file 'include' and it takes the default case and tries to run the code in config.production.php. But that file just contains an opening (but no closing) PHP statement.

    My Solutions

    I've done two different solutions for this (on the 2 sites where I've encountered it). On one I removed the switch code and just pasted all the Perch statements into config.php as I knew I would not need a secondary set of sitepath and database setings. On the other site I've replicated the contents of config.www-mysite-com.php into config.production.php.

    Has anyone else come across this and what's your solution?

    Seems no-one here has tried this, so I've given it some tests.

    The only place I can find the web path to the bucket is in buckets.php, so this should work ...

    1. 'b2backup' => [ 
    2.   'type' => 'amazon_s3', 
    3.   'region' => 'us-west-000', 
    4.   'web_path' => '', 
    5.   'file_path' => 'runway-xxxx', 
    6. ], 

    But Debug reports being unable to find the web path. It appears that the domain gets hard-coded into the request, rather than using the web-path I've provided ...

    1. [message] => Error executing "PutObject" on ""; AWS HTTP error: cURL error 6: Could not resolve host: (see

    We use Backblaze to back up our computers. Backblaze have announced an S3 compatible API for their B2 Cloud Storage, and it is much cheaper than Amazon S3. Has anyone here tried to get Runway backup using this? I thought I’d ask before I attempt to get it working.

    I've been asked to retrospectively add search into a RunWay site. After a fair amount of work (and template adjustments) this is now done. I've also learned some future things affecting the way I build future templates, in case search needs to be added. But I have one issue I cannot resolve ...

    I hold 'vacancies' and 'news' items in collections. Each is set with a 'visible' switch, enabling the author to set up news or a vacancy in advance and then make it visible on pages when they are ready. However, these news/vacancy items still appear in search results whether or not the switch is set.

    Is there a way I can control what is searched and not return a result if the visible switch is not set to 'yes'?

    The template code for each occurrence of this switch is consistent in all templates ...

    <perch:content id="visible" type="checkbox" label="Visible?" value="yes" searchable="false" suppress divider-before="Make this Item visible?" />

    Thanks, Graham

    Thanks. I didn't even know that attribute existed. A search of the documentation only shows it in perch_content_create options. That's a function I've never needed to use, so never spotted it. BTW it works and solves the problem.

    Is there a way of suppressing output from search results? I have a perch:content 'checkbox' and 'select' where the value or option text is appearing in perch:search id=“result_excerpt”. Both the fields have suppress on them and neither field has a title set. Is there another parameter that stops output appearing in search results, or have I missed something?

    I had the same problem. I've just checked my code and I've commented out the 'PerchUtil::redirect('/members/');' line and that made it work. Perhaps it is a timing issue and the 'log_out' doesn't have sufficient time to clear out cookies before the PerchUtil redirect comes into effect? My site setup is such that if you're not logged in, you get redirected to the members home page (to log in again) anyway. So, the PerchUtil line isn't really needed.

    Thanks. I'll give that a try. I obviously missed that.

    The changes are such that it will affect pages that are doing collection searches. The customer staff are not full time and it will take them a few days to adjust the existing 370+ entries. While they are doing that, existing searches will break.

    Is there an easy and obvious way to duplicate a collection? I may have a number of changes to make to one. And the customer will need to consider/edit the existing 370+ entries in the collection. I’m thinking it might be easier to replicate the collection and then the customer can spend as long as necessary editing the entries and then I’ll just switch the code to use the new collection.

    Thanks for the reply. 'News' may well be a renamed 'Blog' app. I think that's part of the renamed files and folders in the App folder and the /core folder. The whole site is Perch and I think they are parsing PHP in .html files. Since I posted the item, things may be moving on. It looks like the existing host may be persuading the customer to go for 'really cheap' hosting that's still supporting many back levels of PHP, so avoiding doing any site work and buying time for another few years. I will 'close' the thread if that looks like the solution she will take.

    I have a customer looking for help, that I can't provide. I host a WordPress site for her, but she also wants me to take on the hosting of an old Perch site as her current host is closing down. Because of my current time constraints, and the 'state' of that Perch site, I can't help - but someone else may be able to do so. Here's the details ...

    The site is It is running on Perch 2.4.2 (January 2014) and PHP 5.6. I no longer run PHP 5.6 on my hosting, so cannot host it in its current state. There are Forms, Blog and News apps installed but I don't think Blog is being used. A simple 'drop in' update to Perch 3.1.5 will not work. The website's author appears to have modified Perch core code*, so a 'drop in' update will likely break the site. The customer is English and has relocated to France, but responds well to email and I'm also in contact with the current host.

    * I briefly look at this a couple of years ago. From memory it looked like the author renamed some core folders and maybe some core files, plus he altered other files to use those renamed folders and files. At the time I decided to leave this alone because the site worked fine on this back level. But things have now moved on.

    If someone is interested in helping, I can put you in touch with the customer and the current host so you can communicate directly during the process of looking over it and updating it. If the site is successfully updated to the latest Perch version, I will be happy to take over the hosting of it and can give you access to move it to my server at the end of the project.

    I suggest you Private Message me with any questions or if you want to be put in contact with the right people.


    Hey Ryan

    There seems to be 3 links on the download page (for accountholders, for 1.5.0). One is to a txt file (that's empty) and the other two are to differently named zip files. Thought you might like to take a look and fix this before other accountholders ask.