Posts by Stephen Meehan

    Hey thanks, that nudged me in the right direction

    Installing a fresh copy of Perch doesn't create a htaccess file for you, so I had to go deep into the archives and find another site I made with a basic htacess file, replaced it with this and cleared the cache.

    1. <IfModule mod_rewrite.c>
    2. RewriteEngine on
    3. # # Redirect to PHP if it exists.
    4. # e.g. will display the contents of
    5. RewriteCond %{REQUEST_FILENAME} !-f
    6. RewriteCond %{REQUEST_FILENAME} !-d
    7. RewriteCond %{REQUEST_FILENAME}.php -f
    8. RewriteRule ^(.+)$ $1.php [L,QSA]
    9. </IfModule>

    Site appears to be working locally now. Phew.


    It's been a while since I worked with Perch (not Runway), I must be missing something obvious - but I just can't see it?

    When visiting a local version of the website I'm seeing this:


    It's downloading the index file?

    - I'm working from a copy of a site from an old server, I've dragged the `public_html` folder off the server so I'm sure all the files are there

    - I've setup the database and updated the config

    - This is an old copy of Perch, so I've made sure I'm using PHP 7.3 locally (for now) as there was an issue with magic quotes being removed in PHP 7.4+

    - There are no errors in the logs

    - My `htaccess` is in the root and looks like this

    I bet it's something super simple...

    Anyone ever hit this?

    Note. Perch works locally if I install a brand new website, I've looked at the fresh install and compared it to this site and nothing obvious seems different?


    My client has requested a specific CRM to be used on a Perch Runway website, the integration is typical - embed a form (iframe) submissions go directly into the CRM, Perch Forms is not being used.

    However the form embed uses cookies, which is a problem in Safari. As Safari does not allow an iframe to set cookies unless a cookie has been set previously in a visit to the domain that is trying to set the cookie.

    The developers of the CRM have created a neat workaround to this Safari only issue.

    They detect Safari, detect the lack of a cookie, redirect back to their website (where the form code is hosted) then redirect back to the website hosting the form. All this happens in the blink of an eye.

    This works in their test environments, but not on the Perch powered website.

    I contacted the developer and they told me:

    "All the page does is set a cookie and then 'redirect to the referrer'. It seems it is getting the referrer rather than - this might be because of client-side routing or similar on your website perhaps?"

    So to recap, the form is on, the script bounces the request to the CRM servers, the script redirects to the referrer which should be but it thinks the referrer is so it's not working?

    Anyone got any ideas what's going on here? :/



    I'm using a solution originally posted by dazglaser and answered by @hus_hmd and ryan

    The code provides the ability to use different templates based on the subcategory level. This gives similar template options as the <perch:pages id="subitems" encode="false" /> but for subcategories.

    It works great, but currently it displays all subcategories.

    I'd like to be able to filter out any subcategories that aren't assigned to an item/post.

    I usually achieve this by using this code:

    Then in the template.html, I use a perch:if

    Here's the code from the original post:

    How would I modify this code to filter out any subcategories that aren't assigned to an item/post? :/

    ...are you outputting the region with perch_content() or perch_content_custom()?


    I was using:

    1. perch_content_create('body', array('template' => '_primary/primary--projects.html')); 
    2. perch_content('body');

    Changing it to

    1. perch_content_create('body', array('template' => '_primary/primary--projects.html')); 
    2. perch_content_custom('body');

    fixed the problem.

    That was it. Thanks so much.


    So, I was running PHP 7.4.2 locally, and debug output this message...

    1. Array
    2. (
    3. [type] => 8192
    4. [message] => Function get_magic_quotes_runtime() is deprecated
    5. [file] => /Users/stephenmeehan/Repositories/burgess-hill/cms/perch/core/lib/PerchDB_MySQL.class.php
    6. [line] => 375
    7. )

    The live site isn't running that version of PHP, so I've changed it to PHP 7.3.9. That message/error is gone.

    But I'm still seeing the wrong perch_page_path


    Hopefully a quick one...

    perch:showall is displaying perch_page_path as /perch/core/apps/content/edit/index.php when it should be... well a page path. This is on a nested page. It's making any perch:ifbased on the page path break.

    Anyone come across this before?

    • Perch Runway: 3.1.5, PHP: 7.4.2, MySQL: mysqlnd 7.4.2, with PDO
    • Server OS: Darwin, cgi-fcgi
    • Installed apps: content (3.1.5), assets (3.1.5), categories (3.1.5), perch_blog (5.6.1), perch_forms (1.12), pipit (0.6)
    • App runtimes: <?php $apps_list = [ 'perch_forms', 'perch_blog', 'pipit', ];
    • PERCH_LOGINPATH: /perch
    • PERCH_PATH: /Users/xxxxxxx/Repositories/xxxxxxx/cms/perch
    • PERCH_CORE: /Users/xxxxxxx/Repositories/xxxxxxx/cms/perch/core
    • PERCH_RESFILEPATH: /Users/xxxxxxx/Repositories/xxxxxxx/cms/perch/resources
    • Image manipulation: GD
    • PHP limits: Max upload 32M, Max POST 8M, Memory: 128M, Total max file upload: 8M
    • F1: xxxxxxx
    • Resource folder writeable: Yes
    • SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
    • REQUEST_URI: /perch/core/settings/diagnostics/
    • DOCUMENT_ROOT: /Users/xxxxxxx/Repositories/xxxxxxx/cms
    • HTTP_HOST: xxxxxxxlocal

    Ah, yes that makes sense.

    I just hoped I was missing something.... I was thrown by event_date_upcoming, it was showing up when I used perch:showall.

    event_date_upcoming is generated using an each callback function, the dates are in a perch:repeater.

    The setup I've got is, each item in the collection can have multiple dates, which are set in a perch:repeater. I'm using the each callback function to change the order of the dates into reverse chronological order. As I can't be sure the admin user will always enter multiple dates in the correct order.

    I was hoping to use event_date_upcoming to filter the collection, but as you pointed out the "each callback function is executed after Perch queries the database"

    Which is fine, I guess. I'll just add a date field in the template and request admin to set the last date of an event manually (so it's in the database). I'll then be able to filter on that. It'll work but it's an extra (small) step for the admin - they all add up :)

    Thanks for confirming how it works, it's good to know.

    Looks like Perch can't use an ID generated from each as a filter value? Is that correct?

    I did this as a test:

    1. perch_collection('Events', [
    2. 'template' => '_events/events--listing.html',
    3. 'filter' => 'postDateTime', // Date item was created 2020-02-20 14:54:00
    4. 'match' => 'eq',
    5. 'value' => '2020-02-20 14:54:00',
    6. 'each' => function ($item) {
    7. ...
    8. return $item;
    9. },
    10. ]);

    postDateTime is a timestamp for when the item was created, and the value 2020-02-20 14:54:00 is just hardcoded in for now, as I know it's the same as postDateTime  . I just wanted to see if it'd work... And it does. Only the item that matches the filter/value is shown.

    So.... Is there a way to get Perch (Runway) to use an ID generated in each as part of filter/value?


    I want to exclude any event items that are older that $now, so only events that are happening now or in the future are displayed.

    The value of event_date_upcoming is different for each item in the perch_collection

    Does this look like it should work?

    event_date_upcoming is generated via a callback, would that have any impact on this working?



    I was hoping Perch Support (hi Drew) could clarify something for me regarding the Members app...

    Does the Members app allow multiple logins using a shared username and password?


    I've used the Members app to password protect a blog and all it's subpages - works great, I was delighted at how easy it was to get setup.

    My client wants to provide a single login to their team. They want the simplicity of emailing a URL to a password protected (staff only) blog, and a single login that everyone in the team will use.

    I've done my own tests to see if multiple visitors can access the blog using the same login, and it appears to work fine. Using the same user/pass, I've logged in on my laptop, and logged in via Members App seems to allow multiple logins using a single user/pass.


    There are couple of (very) old forum posts from Rachel and Drew that suggest the Members App does allow multiple logins using the same user/pass. But these are old posts.

    • I'd like to know 'officially' if this is ok?
    • Is there any reason why this might stop working if 10, 20, 30+ people login using the same username and password?
    • Or does the app not mind?


    Hey, thanks for the replies.

    1. I'm trying to get my head around this, as I've not done this before.
    2. I actually have multiple forms throughout website, will I need an app per form?
    3. I want to use perch_forms to handle validation, redirects and spam.
    4. All I want the form handler to do it pass on the data to the CRM
    5. I'd then add the app ID sm_contact to the form tag <perch:form id="contact" app="perch_forms sm_contact" role="form" method="post" >, correct?
    6. I found the code below on this website
    1. I appreciate the code above isn't what I'd use, but I think it gives me an idea of what I'm trying to achieve.
    2. So, the form handler is used to grab the IDs from the perch:form and converts them into variables, that can be used by a CRM?
    3. How do I get the data in the form handler into the CRM?
      1. Would there be something like an action attribute within the app, this would forward the data to the CRM?


    I need to post a Perch form to a CRM. Not sure how to approach it, as I've never done this before...

    If it was a standard contact form, I'd most likely generate the form in the CRM and use any form code provided.

    This is my current setup. I'm using one Perch form on multiple project pages, depending on where the form is submitted I pass in the project name as a hidden field which then populates the subject field. This approach works really well when everything is done in Perch.

    Can I use Perch forms to collect the form data, including the project name in a hidden field and then pass that on to the CRM?


    Great stuff! Thanks for your help. Here's the working code incase anyone else needs to do something similar.