Partial

Categories

Component ID

187383

Component name

Partial

Component type

module

Maintenance status

Development status

Component security advisory coverage

covered

Downloads

2004

Component created

Component changed

Component body

Partial was created to speed up theme creation and organization by letting developers quickly breakup and reuse small self contained parts of their theme templates.

It favours a set of simple conventions over defining and configuring a set of specific theme functions and implementing theme hooks.

Drupal 7

Usage:

Call partial($name, $variables) the same way you would call theme().

Partial defines a theme suggestion using the pattern “partial__{$partial_name}”.

We suggest that, by convention, partial templates be located in your themes templates/partials sub-folder.

- you can use it directly in a .tpl.php file using the following pattern:

<div class=“page-header”>
  <?php print partial(‘header’, array(‘title’ => $page[‘title’])); ?>
</div>

which will resolves to [path to your theme]/templates/partials/partial—header.tpl.php and make the $title variable available from printing in the theme.

- you can use it in a renderable array using this pattern:

$elements = array(‘title’ => $page[‘title’]);
$build = array(
  ‘header’ => array(
    ‘#markup’ => partial(‘header’, $elements),
  ),
);

and then

<?php print render($build); ?>

Drupal 8

documentation soon to come