Posts by Stephen Meehan

    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?


    PHP
    1. $now = date("Y-m-d h:i:s"); // 2020-04-07 02:57:19
    2. perch_collection('Events', [
    3. 'template' => '_events/events--listing.html',
    4. 'filter' => 'event_date_upcoming', // 2020-03-16 00:00:00
    5. 'match' => 'gte', // Greater than or equal to
    6. 'value' => $now, // 2020-04-07 02:57:19
    7. ]);


    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!

    I have a category set called topics, within the topics category template, I have another perch:categories tag


    HTML
    1. <perch:category required id="catTitle" type="smarttext" label="Title">
    2. <perch:category id="catSlug" type="slug" for="catTitle">
    3. <perch:category id="desc" type="textarea" label="Description" markdown size="s">
    4. <perch:categories id="content_type" label="WLRS categories" set="content-type" notes-before="Select which categories you want to display in this topic.">

    I need to get the category paths from set="content-type", I've done something similar elsewhere in the website I'm working on, but I was using perch_content_custom, that's not possible here as I don't have a region name to work with.


    Here's my PHP


    print_r outputs Array ( [0] => 11 [1] => 12 )



    Not sure why the array isn't showing me the category paths? :/

    Thanks andrewmman / Byron Fitzgerald


    Combining your suggestions did the trick!


    I stuck with catPath as I wanted to replace the hardcoded paths with an array that would contain the category paths.


    PHP
    1. perch_categories([
    2. 'set' => 'content-type',
    3. 'template' => 'category.html',
    4. 'filter' => 'catPath',
    5. 'match' => 'in',
    6. 'value' => 'content-type/case-studies/,content-type/publications/,content-type/resources/',
    7. ]);


    Further up in the template I created $selected_cats, which allows the admin to choose what categories to output on a page.


    PHP
    1. perch_categories([
    2. 'set' => 'content-type',
    3. 'template' => 'category.html',
    4. 'filter' => 'catPath',
    5. 'match' => 'in',
    6. 'value' => $selected_cats,
    7. ]);


    I used $selected_cats as the value.

    Hi,


    I'd like to be able to specify which categories I'd like to be output by perch_categories, I've used a comma delimited string , but only the first category is shown?


    PHP
    1. perch_categories([
    2. 'set' => 'content-type',
    3. 'template' => 'menu.html',
    4. 'filter' => 'catPath',
    5. 'match' => 'eq',
    6. 'value' => 'content-type/case-studies/','content-type/publications/','content-type/resources/',
    7. ]);


    I've tried passing an array into the 'value' like this:


    PHP
    1. perch_categories([
    2. 'set' => 'content-type',
    3. 'template' => 'menu.html',
    4. 'filter' => 'catPath',
    5. 'match' => 'eq',
    6. 'value' => ['content-type/case-studies/', 'content-type/publications/', 'content-type/resources/'],
    7. ]);


    But I get an error in perch:debug: expects parameter 1 to be string, array given


    Anyone know if this is possible? :/

    Thanks for the reply,


    PHP
    1. $result = [$wlrs_selected];
    2. print_r ($result);


    So, $result is an array, print_r gives me


    PHP
    1. Array
    2. (
    3. [0] => 'Listen Up', 'Publications', 'Case Studies'
    4. )


    Unfortunately, I still get the same error when I try to use $result as a collectionKey?


    PHP
    1. perch_collection( $result, [
    2. 'count' => 10,
    3. ]);


    Error:


    No matching collections found. Check collection name ( 'Listen Up', 'Publications', 'Case Studies').



    UPDATE:


    I must be doing something funky to get $result = [$wlrs_selected]; - I'll have to go back to the drawing board on this one!


    If I manually create an array, like this


    PHP
    1. $test_array = ['Listen Up', 'Case Studies', 'Publications'];
    2. print_r ($test_array);

    I get this:


    Array ( [0] => Listen Up [1] => Case Studies [2] => Publications )


    and $test_array works:


    PHP
    1. perch_collection( $test_array, [
    2. 'count' => 10,
    3. ]);

    Hi,


    I'm using this to output multiple collections, (I've removed the rest of the template to keep things clear)

    Code
    1. perch_collection(['Listen Up', 'Case Studies', 'Publications', 'Resources'], [
    2. // TEMPLATE ETC...
    3. },


    It works, but I was wondering if I could set the collectionKeys as a variable like this:


    $test = "'Listen Up', 'Case Studies', 'Publications', 'Resources'";


    As expected, this echoes as:


    'Listen Up', 'Case Studies', 'Publications', 'Resources'


    The same as the collectionKeys, so how come this doesn't work? $test is set at the top of my template, before the perch_collection.

    Code
    1. perch_collection([$test], [
    2. // TEMPLATE ETC...
    3. },


    perch:debug shows this error:


    No matching collections found. Check collection name ('Listen Up', 'Case Studies', 'Publications', 'Resources').



    Even though they are the correct collection names? :/

    Hi,


    Please can we have the ability in Perch Runway to nest perch:blocks inside perch:group


    I've used perch:group to clean up the admin pages, but I'm using a perch:blocks  tag that's related to one of the groups and it's not (visually) sitting inside the group.