How can I show related collection items with block contents in a page?

  • Been a while since I used Perch Runway.
    Anyone able to help shed some light on this? I am trying to use a related collection, which is working but the blocks within the related items are not showing....

    here is the gist:


    ```

    <perch:related id="faqs" collection="FAQ's" label="FAQ's" sort="custom" >

    <details class="expandingBlock // application-notes__item">

    <summary class="expandingBlock__title // application-notes__title"><perch:content id="question" type="text" label="Question" required="true" title="true" /></summary>

    <div class="expandingBlock__content">

    <perch:template path="content/blocks/content-primary.html" />

    </div>

    </details>

    </perch:related>

    ```


    If I stick a <perch:showall> then I get the following back, so it looks accessible.
    The question field is pulling through ok for each item. but none of the blocks.....

  • domain https://www.geomatrix.loc
    url https://www.geomatrix.loc/land…cts/electromagnetic/kt20/
    sitename Geomatrix Earth Science Limited
    description Geomatrix are Milton Keynes based company specialising in the sale and rental of Geophysical{...}
    sharing_image /assets/img/social-sharing-default.jpg
    twittername @GeomatrixES
    og_author https://www.facebook.com/GeomatrixEarthScience
    app_id
    fb_admins
    perch_page_path /land-products/electromagnetic/kt20
    product KT20
    _id 289
    question Geode Seismograph is automatically triggering
    _title Geode Seismograph is automatically triggering
    _blocks
  • drewm

    Approved the thread.
  • As far as I know you can't render perch:blocks inside perch:related tags.


    A workaround could be to render it outside of the template (e.g. in a callback function with the each option):




    And output the rendered HTML inside your template:


    HTML
    1. <perch:content id="faqs_html" html>
  • From what I'm aware of you can't access repeater or blocks namespaces inside the related namespace.


    Your best option is to get the related content from a separate template and store the response as a variable and then output that in your current template.

    Then you should be able to access the HTML with

    Code
    1. <perch:content id="catHTML" html="true" />

    There will most definitely be mistakes with what I've provided above, but the idea should work.