We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem, Runway

Render Slug in Repeater?

I'm creating a custom menu using a repeater. In the repeater template I'm including the page slug. When the template renders it doesn't include the slug of the page. Outside of the repeater it renders the slug fine. Is there a solution?

        <perch:repeater id="tech_menu">
            <li class="">
                <a href="<perch:content id="domain" type="hidden" />/<perch:content id="slug" />/<perch:content id="tech_menu_item_slug" />"><perch:content id="tech_menu_item" /></a>
            </li>
        </perch:repeater>
Dan Lee

Dan Lee 1 points

  • 3 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

https://docs.grabaperch.com/docs/templates/repeaters/

Take a look at the section on "Accessing content outside the repeater"

Dan Lee

Dan Lee 1 points

Here is the solution:

Content from outside the repeater is out of scope. You can bring it into scope within the repeater using the scope-parent="true" attribute on the repeater tag.

To prevent ID clashes, the items from outside the repeater become parent.originalID within the repeater. So a field that is id="title" outside the repeater would be id="parent.title" when brought into scope within the repeater.

        <perch:repeater id="tech_menu" scope-parent="true">
            <li class="">
                <a href="<perch:content id="domain" type="hidden" />/<perch:content id="parent.slug" />/<perch:content id="tech_menu_item_slug" />"><perch:content id="tech_menu_item" /></a>
            </li>
        </perch:repeater>