Forum

Thread tagged as: Question, Problem, Docs
Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to pass it into the template. What have you tried?

Drew McLellan said:

You should be able to pass it into the template. What have you tried?

I did try the normal perch content tag without any luck.

Is there a process to show regions from other templates?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Once you've posted your code I can take a look.

Sorry Drew, that would help!

<perch:before>
<ul class="uk-breadcrumb uk-margin-top uk-margin-bottom uk-float-right">
<li><a href="/">Home</a></li>
</perch:before>
    <li>
        <perch:if exists="perch_item_last">
            <perch:pages id="pageNavText" />
        <perch:else />
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
        </perch:if>
    </li>
<perch:after>
<?php
perch_content_custom('title', array(
    'page'=>'/portfolio.php'
));
?>
<li><perch:content id="title" type="text" label="Title" required="true" title="true"  order="5" /></li>
</ul>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can't put PHP in templates.

Presuming you have a region called 'title', do this in the page:

<?php
PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));
?>

And this in the template:

<perch:before>
<ul class="uk-breadcrumb uk-margin-top uk-margin-bottom uk-float-right">
<li><a href="/">Home</a></li>
</perch:before>
    <li>
        <perch:if exists="perch_item_last">
            <perch:pages id="pageNavText" />
        <perch:else />
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
        </perch:if>
    </li>
<perch:after>
<perch:content id="last_item" encode="false" />
<li><perch:content id="title" type="text" label="Title" required="true" title="true"  order="5" /></li>
</ul>
</perch:after>

Hi Drew,

Thank for for that, unfortunately that has failed to output the title.

This is the code i have in portfolio.php

<div class="page-header">
            <div class="uk-container uk-container-center">
            <div class="uk-grid uk-flex uk-flex-middle uk-margin-top uk-margin-bottom">
            <div class="uk-width-medium-1-2">
                <h2><?php perch_pages_title(); ?></h2>
            </div>
                <div class="uk-width-1-2 uk-float-right"><?php perch_pages_breadcrumbs(); ?></div>
                <?php
PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));
?>
            </div>
            </div>
        </div>

I have updated the breadcrumb template.

Regards

Drew McLellan

Drew McLellan 2638 points
Perch Support

Remember the page is run top to bottom. You can't go back in time and change something once it's already been output.

Hi Drew,

I'm not needing it to change to anything else but output the clients name at the end of the breadcrumb.

I'm not really sure what your last post means!

Regards

Drew McLellan

Drew McLellan 2638 points
Perch Support

This outputs your breadcrumbs.

perch_pages_breadcrumbs();

Then you're calling:

PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));

To pass content into the breadcrumb template, which has already been processed and output.

I'd recommend passing the content into the template before using the template.

Hi Drew,

Again i am always looking to the docs, how would one does this?

Thank you.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The page runs top to bottom.

PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));
perch_pages_breadcrumbs();

Drew,

This was something i already tried from your first post regarding top to bottom but i thought that would be to easy for Perch :(

This does not work.

<div class="page-header">
            <div class="uk-container uk-container-center">
            <div class="uk-grid uk-flex uk-flex-middle uk-margin-top uk-margin-bottom">
            <div class="uk-width-medium-1-2">
                <h2><?php perch_pages_title(); ?></h2>
            </div>
                <div class="uk-width-1-2 uk-float-right"><?php
PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));
perch_pages_breadcrumbs(); ?></div>
            </div>
            </div>
        </div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

What happens?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hmm, ok. Show me your template as it is now...

Thank you Drew.

portfolio.php

<?php include( 'perch/runtime.php');?>
<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js">
<!--<![endif]-->

<head>
    <title>
        <?php perch_pages_title(); ?> </title>
    <?php perch_layout( 'global.meta'); ?>
    <?php perch_layout( 'global.fileassets'); ?> </head>

<body>
    <!--[if lt IE 7]>
          <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="https://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
    <?php perch_layout( 'global.header'); ?>
    <!-- nav -->
    <nav class="uk-navbar uk-visible-large">
        <div class="uk-container uk-container-center">
            <?php perch_pages_navigation(array( 'from-path'=> '/', 'hide-extensions' => true, 'include-parent' => true, 'template' => 'main-nav.html', ));?> </div>
    </nav>
    <!-- nav end -->
    <!-- slider -->

    <!-- slider end -->
    <!-- portfolio items -->
    <div class="page-header">
            <div class="uk-container uk-container-center">
            <div class="uk-grid uk-flex uk-flex-middle uk-margin-top uk-margin-bottom">
            <div class="uk-width-medium-1-2">
                <h2><?php perch_pages_title(); ?></h2>
            </div>
                <div class="uk-width-1-2 uk-float-right"><?php
PerchSystem::set_var('last_item', perch_content_custom('title', array(
    'page'=>'/portfolio.php'
), true));
perch_pages_breadcrumbs(); ?></div>
            </div>
            </div>
        </div>
    <div class="uk-container uk-container-center uk-margin-top uk-margin-bottom">
        <div class="uk-grid uk-margin-bottom uk-margin-top" data-uk-grid-margin>
            <div class="uk-width-medium-4-5 uk-flex-middle">
                <?php
    perch_content_create('Portfolio', array(
      'template'   => 'portfolio_item.html',
      'multiple'    => true,
      'edit-mode' => 'listdetail',
    ));
    ?>
    <?php
    perch_content_custom('Portfolio', array(
      'template' => 'portfolio_listing.html',
    ));
    ?>
            </div>
            <div class="uk-width-medium-1-5">
            <h3>Categories</h3>
                <?php
 {
      perch_categories();
    }
    ?>
            </div>
        </div>
    </div>
    <!-- portfolio items end -->


    <?php perch_layout( 'global.footer'); ?>
    <!-- Off canvas menu -->
    <div id="sidemenu" class="uk-offcanvas">
        <div class="uk-offcanvas-bar">
            <?php perch_pages_navigation(array( 'from-path'=> '/', 'hide-extensions' => true, 'include-parent' => true, 'template' => 'offcanvas.html', ));?>
            <div class="uk-text-center uk-margin-large-top"> <img src="/images/logo-vert-nav.png" width="198" height="144" alt="company logo vert"> </div>
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script src="/js/uikit.min.js"></script>
    <script src="/js/plugin.js"></script>
    <script src="/js/main.js"></script>
    <script src="/js/retina.min.js"></script>
    <script src="/js/components/slideshow.min.js"></script>
    <script src="/js/components/slideshow-fx.min.js"></script>
    <script src="/js/components/cover.min.js"></script>
    <script src="/js/components/grid.min.js"></script>
    <script src="/js/components/sortable.min.js"></script>
    <!-- Google Analytics ID -->
    <script>
    (function(i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r;
        i[r] = i[r] || function() {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date();
        a = s.createElement(o),
            m = s.getElementsByTagName(o)[0];
        a.async = 1;
        a.src = g;
        m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
    ga('create', 'UA-47548290-1', 'auto');
    ga('send', 'pageview');
    </script>
</body>
</html>

Breadcrumb

<perch:before>
<ul class="uk-breadcrumb uk-margin-top uk-margin-bottom uk-float-right">
<li><a href="/">Home</a></li>
</perch:before>
    <li>
        <perch:if exists="perch_item_last">
            <perch:pages id="pageNavText" />
        <perch:else />
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
        </perch:if>
    </li>
<perch:after>
<perch:content id="last_item" encode="false" />
<li><perch:content id="title" type="text" label="Title" required="true" title="true"  order="5" /></li>
</ul>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Gah! Replace <perch:content with <perch:pages !

Ok i have updated that in the breadcrumb still with no luck :(

<perch:before>
<ul class="uk-breadcrumb uk-margin-top uk-margin-bottom uk-float-right">
<li><a href="/">Home</a></li>
</perch:before>
    <li>
        <perch:if exists="perch_item_last">
            <perch:pages id="pageNavText" />
        <perch:else />
            <a href="<perch:pages id="pagePath" />"><perch:pages id="pageNavText" /></a>
        </perch:if>
    </li>
<perch:after>
<perch:pages id="last_item" encode="false" />
<li><perch:content id="title" type="text" label="Title" required="true" title="true"  order="5" /></li>
</ul>
</perch:after>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you add the following to the perch:after section and let me know what it outputs?

<perch:showall />