Partials

Partials contain common markup, widgets, and any other content shared by multiple layouts and/or views.

Partials are typically small files containing similar content as your views and layouts, the only difference being that partials are intended to be reusable: whereas a view is always tied to single template, multiple views (and layouts) can use the same partial.

Example partial

Here's one example of a partial file (/site/templates/partials/menu/breadcrumbs.php):

<?php namespace ProcessWire; ?>
<nav aria-label="Breadcrumbs" class="breadcrumbs">
    <ul class="breadcrumbs__list">
        <?php foreach ($page->parents as $item): ?>
            <li class="breadcrumbs__list-item">
                <a class="breadcrumbs__item" href="<?= $item->url ?>">
                    <?= $item->title ?>
                </a>
            </li>
        <?php endforeach; ?>
        <li class="breadcrumbs__list-item">
            <span class="breadcrumbs__item breadcrumbs__item--active" tabindex="0" aria-label="Current page: <?= $page->title ?>">
                <?= $page->title ?>
            </span>
        </li>
    </ul>
</nav>

A partial can be embedded into a view file using PHP's own include or require statements:

<?php
include 'partials/menu/breadcrumbs.php';

Note that the /site/templates/ directory is automatically added to PHP's include path, so you can refer to partials with a relative path, such as in the example above. In addition Wireframe provides an alternative, object-oriented way to refer to partials:

<?php
include $partials->menu->breadcrumbs;
Back to top