Posts by Stephen Meehan

    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.

    Hi,


    [SOLVED] - See end of post


    Is it possible to use the ID of a perch:related tag in a filter?


    I'm using the code below to display a featured card in a sidebar. It's displayed everywhere, except on the page it's promoting. The idea being when a user is on that page the card isn't shown.


    It works, but there are four perch:related tags that the CMS admin could pick. So having the ID feat_listen_up hard coded isn't very flexible.



    I've created $related_id using the code below:


    Code
    1. $related_id = perch_collection('Opportunities', [
    2. 'filter' => 'opp_name_slug',
    3. 'match' => 'eq',
    4. 'value' => perch_get('s'),
    5. 'skip-template' => 'true',
    6. 'return-html' => 'true',
    7. ]);


    Update:

    The example below checks if an ID is set, if is, it sets $related_id_filter  which I then use in one of the filters.


    Hi


    Thanks for the example, unfortunately I couldn't get it to work - however I was able to use implode(',', $wlrs_cats[0]['content_type']) to get what I was looking for. Thanks!


    This outputs the category paths of the current item filtered by slug:



    So $categories; outputs content-type/listen-up/,content-type/case-studies/


    I wanted to use the category path to allow the admin to choose what categories to show in another collection.


    So I used this to convert the category paths into a variable I could use in another template



    This takes the category paths


    content-type/listen-up/,content-type/case-studies/


    and leaves me with just the category name, which I then uppercase and remove the hyphen. This then matches the the name of an ID in another template which then lets me use perch:if


    <perch:if id="wlrs_cats_edit" match="contains" value="{collectionKey}">...</perch:if>


    Thanks for your help hus_hmd :)

    Thanks for the reply.


    If I use perch_categories() or perch_category() how do I relate them to the perch_collection?


    Within perch_collection('Opportunities' the admin might select one or all four categories, I'm looking for a way to expose the category paths. I'm hoping I can then convert them into a variable and use them as part of a filter, to filter a different perch_collection