Posts by Stephen Meehan

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


    Aha!


    I was using:

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

    Changing it to


    Code
    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.

    Hi,


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


    Code
    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

    Hi,


    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:

    Code
    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?

    Hi,


    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?


    :/

    Hi,


    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 browserstack.com. 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?

    Hi,


    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.


    :)

    Yes, that's right. Dates for each event are added via a repeater, there could be one date or multiple dates per event.


    I've got this half working


    PHP
    1. perch_collection('Events', [
    2. 'template' => '_events/events--listing.html',
    3. 'sort'=>'postDateTime',
    4. 'sort-order'=>'DESC',
    5. 'each' => function($item) {
    6. $item['list_event_date'] = $item['event_dates'][0];
    7. return $item;
    8. }
    9. ]);


    id="list_event_date" is in events--listing.html and takes it's value from the first array in perch:repeater id="event_dates"


    But, I'm not sure how to change the order of the dates in perch:repeater id="event_dates", ideally it needs to be in reverse chronological order so the next upcoming date is shown, not just the first date in the array.


    An admin user might (accidentally) add the dates like this


    - 25th Feb, 2020

    - 12th Feb, 2020

    - 19th Mar, 2020


    My code at the moment would display, 25th Feb, 2020 (the first date in the array). When I'd need it to show 12th Feb, 2020 as that's the next event.

    Hi,


    I have a collection called Events, each item has perch:repeater id="event_dates" which can have multiple dates, that might not be in the desired reverse chronological order.


    events--listing.html needs to show the next upcoming date, I feel like this is a job for a callback function. Loop through each item in the collection, order dates and output the first date in the array, then output the HTML


    I can't figure out how to apply arguments to the $item in the callback...


    Ah, I didn't know about _id, very useful.


    There's also another collection for event locations inside the event collection, I needed to grab the location associated with the event. I was able to do it using the same technique but on another collection.


    Thanks! :)

    Hi,


    I have a hero banner, which allows admin to pick a featured event from a collection. It works but I need to do some other things with it.


    The events--hero.html template has this perch:related id="feat_event" tag, using perch_content_custom I need access to the IDs inside perch:related


    This is what I have so far:

    PHP
    1. $feat_event = perch_content_custom('Hero', [
    2. 'template' => '_events/hero/events--hero.html',
    3. 'skip-template' => true,
    4. 'return-html' => true,
    5. ]);
    6. $feat_event_hero = $feat_event[0]['feat_event'];
    7. pipit_r ($feat_event_hero);

    Unfortunately, $feat_event_hero only displays this array:

    Code
    1. Array
    2. (
    3. [0] => 9
    4. )


    This is my events--hero.html template. If I place <perch:showall> inside perch:related I can see all the IDs.

    HTML
    1. <perch:related id="feat_event" collection="Events" max="1">
    2. <perch:showall>
    3. <!-- Template IDs here... -->
    4. </perch:related>


    Is there a way to access the IDs inside perch:related id="feat_event"? using perch_content_custom:/

    Hi,


    I get how to pass a variable into a layout, like this:

    PHP
    1. // template.php
    2. perch_layout('head', array(
    3. $demo => 'THIS IS A DEMO',
    4. ));

    Then inside head.php I'd use this:

    PHP
    1. // head.php
    2. perch_layout_var($demo);

    which would output THIS IS A DEMO. Great.



    Is it possible to do the reverse? Pull a variable out of perch_layout('head')?



    At the top of post.php I have perch_layout('head'), this contains lots of global php variables I'd like reuse in other templates.


    As an example, in perch_layout('head') I have this variable:


    PHP
    1. // head.php
    2. $test = 'THIS IS A TEST';


    I'd like to use $test in post.php


    PHP
    1. // post.php
    2. perch_layout('head');
    3. // Using pipit add-on to format print_r
    4. pipit_r($test);


    In perch debug I get an error: [message] => Undefined variable: test


    Is there a way to use $test in a template without having to recreate it?

    Great stuff! Pipit is super useful.


    Here's how I used it.


    I can then do other stuff to $topic_selected, but the key thing is the category paths are output as paths not IDs


    Thanks!