Posts by hus_hmd

    Creating the form template for this is fine, but would this require a custom app to send the data to the collection?

    Correct. In your form template you would add your app ID in the app attribute:

    1. <perch:form app="gary_app_id"></perch:form>

    Your form handler function would go in your app's runtime file perch/addons/apps/gary_app_id/runtime.php:

    1. function gary_app_id_form_handler($SubmittedForm) {
    2. if ($SubmittedForm->validate()) {
    3. }
    4. }

    Apologies, I didn't really grasp the need for using the collection import API.

    The Collections import API provides a way to interact with a Collection's items. Inside the form handler of your app you have access to data submitted by a user. This data is not saved in the database. It is your responsibility here to handle the data as you need. In this case you want to add the data to a Collection item. The import API is a documented and supported way to do that.

    Hello Gary,

    You can keep using Perch Members for user authentication, but you may have to manage the profiles outside of it. Even if you write a custom form handler to handle the file uploads, there's no public API for locating and updating Members.

    One option is to use a Runway Collection for the profiles and link each member to a Collection item. You'd need to write a custom form handler and use the collection import API to locate and update the Collection items. If you are dealing with images, you can also import them as Perch Assets or perhaps upload them straight to something like Cloudinary and only record the image URL in Perch.

    Your post_search_result.html template is like any other blog template. You need to use the perch:blog name space and you need to use the actual blog post fields. You are no longer in the context of the search there.

    So you would use:

    1. <h2><a href="<perch:blog id="postURL" />"><perch:blog id="postTitle" /></a></h2>

    What is the 'post_search_result.html' page supposed to look like? Just like the search-result.html?

    It should be used to output the search results of a single blog post.

    I'm limiting the search to /community (which we call our Blog) so all results all blog-only (which we want). But the results are showing in the regular layout from the search-result.html template. With some testing, I see it's pulling in the post_search_result.php layout, but it's stopping there.

    If you want to limit the search results to the Blog app, you would use the apps option:

    1. perch_content_search(perch_get('q'), [
    2. 'apps' => ['PerchBlog'],
    3. ]);

    Using Perch Runway 2.8.29 ......does that mean I need ending slashes somewhere?

    Yes. Your template tags need to be self-closing />.

    My comment included the path for each template ^^!

    The function perch_content_search() uses the template templates/search/search-result.html by default. I'll assume you are using that.

    With the search-result.html template you output the HTML for regular search results. However, when the search result source is the Blog app you use a Perch Layout include to output the search result item. Perch Layouts are PHP files. So the following:

    1. <perch:layout path="blog_search_result" url="<perch:search id="result_url">">

    Includes the PHP file templates/layouts/blog_search_result.php. Inside this file you use the function perch_blog_custom() to output the blog search result. This function renders another HTML template. The template you render with this function has to be placed in the directory templates/blog/ like all your other Blog app templates.

    In other words, if it's a regular search result:

    perch_content_search() -> templates/search/search-result.html

    If the search result source is the Blog app:

    perch_content_search() -> templates/search/search-result.html -> templates/layouts/blog_search_result.php (which uses perch_blog_custom()) -> templates/blog/post_search_result.html

    Where to I put the show all tag? I've tried a few spots, but I don't see anything.

    You would add it to your search results template.

    If you really need to make all the Blog post fields available in search result, there are workarounds. I'll go over one:

    Add conditional tags to separate the search results based on the source:

    Add a Perch Layout include and pass the result URL as a Layout variable:

    1. <perch:if id="result_source" value="PerchBlog">
    2. <!--* Search result from the Blog app *-->
    3. <perch:layout path="blog_search_result" url="<perch:search id="result_url">">
    4. <perch:else>
    5. <!--* Everything else *-->
    6. </perch:if>

    Create /perch/templates/layouts/blog_search_result.php and filter the posts using the result URL:

    1. <?php
    2. perch_blog_custom([
    3. 'template' => 'post_search_result',
    4. 'filter' => 'postURL',
    5. 'value' => perch_layout_var('url', true),
    6. ]);

    Create the template /perch/templates/blog/post_search_result.html and include any Blog post field you want.

    You would add your filter options alongside the data option. Assuming you have a field with the ID slug:

    1. perch_content_custom('Products', [
    2. 'filter' => 'slug',
    3. 'match' => 'eq',
    4. 'value' => perch_get('p'),
    5. 'data' => [
    6. 'default_banner' => perch_content('Banner', true),
    7. ],
    8. ]);

    Hello David,

    Is there a way of getting a field from a region in (product_page.php) into a region in (product_page.php?p=every_other_page) to do a compare with perch:if in a template?

    These two are technically the same page. Anyway, if you want to get a region from another page, perch_content_custom() has a page option which allows you to do this.

    I thought they had to be in the same runtime?

    perch_content() outputs the region as evaluated and rendered when saved in the control panel. perch_content_custom() outputs the region as evaluated and rendered at run time (when the page is visited).

    You have 2 regions, (A) a banner (B) a list of products. To make something from (A) available in (B), (B) has to be output with perch_content_custom().

    Assuming (A) only contains the banner with the same HTML you need:

    1. perch_content_custom('Products', [
    2. 'data' => [
    3. 'default_banner' => perch_content('Banner', true),
    4. ],
    5. ]);

    perch_content('Banner', true) gets you the rendered template (HTML included). Below the default_banner outputs the HTML too:

    1. <perch:if exists="bannerimage">
    2. <div class="static-banner" style="background-image: url(<perch:content id="bannerimage" type="image" width="1400" height="200" crop="true" help="Add a full width banner image with a minimmum with of 1400px" />);">
    3. </div>
    4. <perch:else>
    5. <perch:content id="default_banner" type="hidden" html>
    6. </perch:if>

    If you only need to grab a field value, you'll have to use perch_content_custom() and the skip-template option to grab the field in PHP.