Forum

Thread tagged as: Question, Runway

Passing breadcrumbs into template

Hi

I'm trying into pass breadcrumbs into a content template like this previous post but I am not getting anything outputted.

Page code /perch/templates/pages/blog/index.php:

    $breadcrumbs = perch_pages_breadcrumbs(array(), true);
    PerchSystem::set_var('breadcrumbs', $breadcrumbs);
    perch_content('Hero');

Breadcrumb template /perch/templates/navigation/breadcrumbs.html:

<perch:before>
    <p class="breadcrumbs"><a href="/">Home</a><span>/</span>
</perch:before>
        <perch:if exists="perch_item_last">
            <perch:pages id="pageNavText" />
        <perch:else />
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a><span>/</span>
        </perch:if>
<perch:after>
    </p>
</perch:after>

Content template /perch/templates/content/hero.html:

<section class="hero<perch:if not-exists="heroImg"> hero-mini</perch:if>" style="background-image:url(<perch:content id="heroImg" type="image" label="Hero background image" width="1920" height="1008" crop="true" bucket="backgrounds" help="Image will be cropped at 1920 x 1008 pixels" />);">
    <div class="container">
        <div class="row">
            <div class="col-lg-8">
                <perch:content id="breadcrumbs" encode="false" type="hidden" />
                <h1><perch:content id="text" type="text" label="H1 page title" /></h1>
                <p class="lead"><perch:content id="intro" type="textarea" label="Introduction paragraph" /></p>
            </div>
        </div>
    </div>
</section>

...knowing me it's something really simple but any help would be much appreciated.

Glen

Glen Piggott

Glen Piggott 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

perch_content() uses a cached version of the HTML which is precompiled at edit time.

If you need it to render 'live' you should use perch_content_custom().

Perfect, thanks Drew.

All working using perch_content_custom()