Posts by hus_hmd

    Hello,


    I'm unable to parse paired tags in the context of a template handler using PerchTemplate's parse_paired_tags() as it is a private function.


    PHP
    1. $html = $Template->parse_paired_tags($tag_type, $empty_opening_tag, $html, $vars, $index_in_group, $callback);


    Is the expectation that I implement my own parser function here?

    That was just an example demonstrating that you can use dynamic values for filtering from Page Attributes. You ideally need to check if the page attribute returns a value before you apply the filter.



    Try with hard-coded values. Does it work as you expect?


    PHP
    1. perch_collection('Examples', [
    2. 'filter' => 'my_field', // field ID in template <perch:content id="my_field">
    3. 'match' => 'eq',
    4. 'value' => 'value I am looking for', // field value
    5. ]);


    I'm getting an error - what did I miss here

    I can't help if I don't know what the error is :S



    the region with the text field is "tags"


    Are you using Regions or Collections?





    p.s. I'm not sure I follow with tags/case. I'm assuming you have a field with the ID tags (and the value you entered for this field is case) :


    HTML
    1. <perch:content id="tags" ... >


    Anyway, field ID and field value are good descriptive terms. So let's just use these so we're all on the same page.

    Can you hardcode the filter? If you can and it works as desired, you can make it dynamic:


    PHP
    1. $filter = perch_page_attribute('resources_filter_field', [], true);
    2. $value = perch_page_attribute('resources_filter_value', [], true);
    3. perch_collection('Examples', [
    4. 'filter' => $field,
    5. 'match' => 'eq',
    6. 'value' => $value,
    7. ]);

    I use layouts includes in templates occasionally. It's a quick way to "bring" PHP into a template. As you pointed out it's easy to pass editable content to a layout like this.


    on a page by page basis


    For customising things on the page level, you'd normally use Page Attributes which you can get in PHP in your global.header.php:


    PHP
    1. $header_image = perch_page_get_attribute('header_image');

    Hello marc,


    I think the response is processed independently by the apps listed in the app attribute.


    You can list your app app="boldr_recaptcha" without perch_forms and redispatch to the Forms app via your app form handler if Recaptcha is successful:


    Code
    1. $SubmittedForm->redispatch('perch_forms');


    This means no spam responses would be stored in Perch Forms though.

    Could you clarify? If you're using skip-template then nothing in the template is used, including calls to layouts. So I'm clearly missing something!


    True, but I'm also using the return-html option. I'd want the layout included in the returned HTML.


    Setting pagination-var should be enough! What do you have set for the paging key in your config/runway.php file?


    I haven't set one.

    Hello,


    I'm extending the PerchFactory class in an app and ran into a few things. My classes don't specify an index table so ultimately I'm using get_filtered_listing(), not get_filtered_listing_from_index().


    Some of the below may be intentional and designed that way. And of course there's always the possibility I've implemented something incorrectly. None of the below is preventing me from achieving what I need, so just reporting in case any of this behaviour is not intentional.

    Layout includes


    I sometimes use Layout includes inside templates:


    HTML
    1. <perch:layout path="my_layout">


    This generally works. However, it doesn't when using the skip-template option. I resorted to using a template handler instead.



    Paging automatically enabled (when using count)

    When using the count option, paging seems to be automatically enabled regardless of the value of the paginate option.


    This is fine if I I'm only fetching one set of data on the page. However, if I'm fetching 2 or more sets of data and I only need one of them to be paginated, while the other(s) still needs to be limited by the count option, both sets will be paginated.


    I'll use demo_collection() below for demonstration:



    Using the start option is the only way I've found to actually disable the pagination:


    PHP
    1. demo_collection('Unicorns', [
    2. 'count' => 3,
    3. 'start' => 1,
    4. ]);


    ?page= always works


    Before I tried the start option I attempted to assign a different query string parameter name using the pagination-var option. The custom name I assign works, but ?page= also works regardless.



    PHP
    1. // default ?page=
    2. demo_collection('Elephants', [
    3. 'count' => 9,
    4. ]);
    5. // custom ?p=, default ?page= still applies here regardless
    6. demo_collection('Unicorns', [
    7. 'count' => 3,
    8. 'pagination-var' => 'p'
    9. ]);


    The custom name is used as expected in the pagination URLs in the template, but if I visit ?page=12, I'd get the 12th page for both Elephants and Unicorns; not just Elephants. So I'd have to refrain from using ?page= altogether to avoid unintentionally paginating something else on the page.

    Hello davedesigner


    Assuming your category set sale has only 2 categories, you can check for the total number of selected categories: if you have 2 categories, you know both for-sale and for-rent are selected:



    Note this is a workaround. It checks for how many categories selected, not whether the selected categories are forfor-sale and for-rent. If you have more categories in this set, this approach wouldn't be suitable.

    so the template was using <perch:sample> and that worked with it as is, but with your $filtered_things code the namespace was <perch:content> and now it works!

    You can specify the namespace you want to use in your class:


    PHP
    1. class MySample_Things extends PerchAPI_Factory {
    2. protected $namespace = 'sample';
    3. .
    4. .
    5. .
    6. }



    Running into an issue where it will only filter by the default tags. Does this mean it will only filter columns that aren't in the dynamic content field?

    Correct. You can't filter by dynamic fields unless you have an index table.

    When you say empty, do you mean the template doesn't output any content (just the HTML markup)?


    If so, to check what you have access to inside the template you can use <perch:showall>. Alternatively, you can use the skip-template option and inspect the returned items in PHP.

    In the absence of collections. I was thinking I could have a template which lists all the locations (other_locations.html) and have that as a shared region. Hence the client only has to input the data once.


    The closest thing to a collection in regular Perch is a multiple-item region. You can display the region on any page using the page option:


    PHP
    1. perch_content_custom('Locations', [
    2. 'page'=>'/locations/index.php',
    3. 'template'=>'locations_list.html',
    4. ]);


    Collections are more powerful, but you get a lot of the same features like filtering. So if you are viewing the detail page of location 2, you can list the other locations and exclude location 2 with a filter. Assuming each location has a slug:


    That's the default category for the sub-levels (it's inside a function called get_sub_categories()). Apologies if my comment caused some confusion.


    The first level is output by the initial perch_categories() call: