Posts by hus_hmd

    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:


    HTML
    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:


    PHP
    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:


    HTML
    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:


    HTML
    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:


    PHP
    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:


    PHP
    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:


    PHP
    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:


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

    I think it's common to have a single edit form for all products on an e-commerce platform as all products would need to share the same shop-related fields (pricing, shipping, stock, etc). If we had an additional tab labelled "content" for example, it would make sense to allow the editors to choose different templates for that tab alone. The main edit form tab has to remain the same though.


    if you have lots different products with different specifications and they all have to be input via the one form template

    Different specifications in what aspects? The content you want to enter/display? Perhaps you can use field groups to group some of the content fields? Or even use Blocks so you only add those fields to the form when required?



    using the admin "add product" form could become unmanageble very quickly.

    Perch offers a number of ways to organise your edit form template and make it manageable and easy for the editor to follow including Field Groups, divider-before, divider-after, notes-before and help tags. So you can group and separate fields as well as add helpful notes to the editors.


    You can, for instance, group stock fields:


    HTML
    1. <perch:group label="Stock">
    2. <perch:shop id="stock_status" type="shop_stock_status" label="Stock status" required>
    3. <perch:shop id="stock_level" type="number" label="Stock level" size="s">
    4. <perch:shop id="stock_location" type="shop_stock_location" label="Count stock">
    5. <perch:shop id="max_in_cart" type="number" label="Max quantity in cart" size="s">
    6. </perch:group>