Posts by hus_hmd

    If I have a Collection of member biographies (with different field types like text and image), does this mean that a member or admin user would be able to edit these?

    Yes! Someone who's registered as a member via the Perch Member app would be able to edit this.

    A member should be able to edit their own biography not others. Is that possible?

    Assuming the collection items are linked to the relevant members (e.g. by relating them using the Members field type), you can only display the edit form to the relevant member.

    In a member-only page, you can filter by the member ID:

    And you can expand this to a list/detail pattern where the member is allowed to create/edit multiple items (e.g. a ticketing system):

    So you are controlling what items a member edits.

    The one thing this lacks right now is stricter checks at the form handler level. While the form is CSRF protected, a malicious user technically can edit the values of the hidden _id and member fields on the form.

    Normally you'd check the logged in member submitting the form is the same member linked to the item. The reason I have not implemented this check in Pipit Members yet is I find the identifying link to the collection item is not necessarily the member ID. So I'm working on implementing a way to allow you (the developer) to define this check.

    I've recently released Pipit Members v1.1.0 which makes it easier to allow members (registered with the first-party Perch Members app) create/edit/delete collection items via Perch-templated forms:

    This essentially makes it easier to build CRUD apps with Perch Runway without having to write your own custom Perch apps. You would use:

    I'm posting here to open a dialog with other developers. So feel free to share your thoughts, request features that would make it even easier for you or ask questions.

    Assuming you are using a Perch-templated form like the example in the docs:

    You can generation the options in PHP:

    1. <perch:input type="select" id="location" options=",<perch:forms id="cat_opts">">

    Or you can generate the options in a separate template:


    1. <perch:category id="catTitle">|<perch:category id="catSlug"><perch:if not-exists="perch_item_last">,</perch:if>

    I don't recall coming across this myself. A quick Google search suggests you may see this if your server does not support gzip compression. So I would:

    • Enable gzip compression on the server
    • If that doesn't work, check your error log and/or turn on Perch debug mode

    Hi Tony,

    The slug you generate does not need to include the item's unique ID in order for you to use it in the item's URL and when fetching the item from the database. The item's URL in your template can be something like this:

    1. <a href="/post.php?s=<perch:content id="slug">-<perch:content id="_id">">
    2. <perch:content id=title">
    3. </a>

    In your PHP page, you can get the value of ?s= (i.e. the item's slug in this case) with perch_get('s') and separate the last segment of the slug:

    I'd personally use the _id option (because Perch uses a faster a database query with it), and check the slug from the URL matches the slug I get from the database in PHP:

    1. $item = perch_collection('Blog', [
    2. '_id' => $ID,
    3. 'skip-template' => true,
    4. 'return-html' => true,
    5. ]);

    Hi Tony,

    Yes, this is possible. One approach is to use layout includes inside the template and pass layout variables:

    1. <perch:layout
    2. path="products"
    3. categories="<perch:categories id="category" set="products" label="Category"><perch:category id="catPath" append=","></perch:categories>"
    4. >

    Given that layouts are rendered at a later phase than normal content, when Perch renders them it will see the tag as something like:

    1. <perch:layout
    2. path="products"
    3. categories="products/shoes/,products/shirts/,"
    4. >

    So the above is the equivalent to:

    1. perch_layout('products', [
    2. 'categories' => 'products/shoes/,products/shirts/,'
    3. ]);

    Inside your templates/layouts/product.php, you can access the categories with perch_layout_var():

    since I used perch_content_create() there's no region, so I think that's not going to work

    perch_content_create() creates a region if it doesn't already exist. So this won't prevent you from using the dataselect field type.

    Also I'm unsure whether that can do multiple Projects anyway.

    If the dataselect field type does not support selecting multiple items, you can use repeaters!

    Why not use the Perch Gallery addon?

    The issue with the Gallery app is not only that it is not being maintained, but also the fact that it does not use the central assets system. This means if the editor wants to use the same image in different parts of the site besides the gallery (e.g. a blog post or a content region), they'd need to upload the same image twice.

    You can use the html attribute for this:

    1. <perch:content id="code" type="textarea" label="Code" html>

    In fact, Perch ships with a sample template for this perch/templates/content/code_block.html

    For example, on a Florist website where you are shown extra items to buy with your flowers, such as a balloon, card, etc. These would be shown on the product detail page and can be ordered directly from that page alongside the main product.

    This can be achieved in different ways.

    For example, these items can be added as options and you'd have variants like:

    • Flowers
    • Flowers + [colour] balloon
    • Flowers + [colour] balloon + card

    The UI on the page doesn't have to be a list of form inputs. You still have some flexibility.

    Another approach is to have separate products and link them in some way (e.g. categories, or by relating products with the productlist field type). Adding different products to the cart at once is possible (if not through Perch Shop's existing functionality, it would be possible to write a custom add-on to do this).

    Would it help if I uncheck "Edit all items on one page"?

    Yes, possibly! PHP by default has a maximum of 1000 input variables (CMS fields in this case) - see max_input_vars. So by having that many items in a single form yo'll eventually hit that maximum. I would uncheck the option and manage each item on its own page.

    However, given that now 450 is a lot of entries, is there an easy way to delete multiple items quickly?

    There's no way to do this currently as far as I know.