Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: MCP Sentinel 2.28.2 — Minor update available for module mcp_sentinel (2.28.2). Release: Rightup theme 1.0.2 — Minor update available for theme vartheme_bs5_rightup (1.0.2). Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage. Module Revived: Liquid Voting 2.0.1 — Module liquid_voting updated after 6 months of inactivity (2.0.1).

Partial

Security covered
View on drupal.org

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 8/9

Usage:

Partial returns a rendered version of the template that you can just output.

Here is a simple use case using a #markup element in a render array.

    $content['sections']['archives'] = [
      '#markup' => partial('documentation_section'),
    ];

Here is a nested partials example showing how to also pass variables around to a partial template.

    $content['sections']['archives'] = [
      '#markup' => partial('documentation_section', [
        'id' => 'archives',
        'title' => $this->t('How to create an archive'),
        'content' => partial('documentation_archive'),
      ]),
    ];

Partial defines a theme suggestion using the pattern “partial__{$partial_name}”. (Remember that Drupal defines suggestions using underscores, but filenames use dashes, see further bellow)

We suggest that, by convention, partial templates be located in your themes templates/partials sub-folder. So in the above example you would be creating two template files respectively called partial--documention-section and partial--documention-archive.

Twig Extension - Function & Filter

The module also provides Twig extensions

Usage:

Examples needed

Drupal 7

Usage:

Partial returns a rendered version of the template that you can just output.

Here is a simple use case where

    $content['sections']['archives'] = [
      '#markup' => partial('documentation_section'),
    ];

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); ?>

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Oct 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
2.0.x-dev Dev Oct 25, 2023