Run prettier on all *.md files

```
prettier '{app,source}/**/**.md' --write
```
This commit is contained in:
Oliver Davies 2020-03-08 17:52:59 +00:00
parent a3ceeaf0f3
commit 85a10c545b
170 changed files with 5127 additions and 2282 deletions

View file

@ -1,23 +1,36 @@
---
title: Dividing Drupal's process and preprocess functions into separate files
date: 2012-05-24
excerpt: If you use a lot of process and preprocess functions within your Drupal theme, then your template.php can get very long and it can become difficult to find a certain piece of code. Following the example of the Omega theme, I've started separating my process and preprocess functions into their own files.
excerpt:
If you use a lot of process and preprocess functions within your Drupal theme,
then your template.php can get very long and it can become difficult to find a
certain piece of code. Following the example of the Omega theme, I've started
separating my process and preprocess functions into their own files.
tags:
- drupal
- code
- theming
- preprocessing
---
If you use a lot of process and preprocess functions within your Drupal theme, then your template.php can get very long and it can become difficult to find a certain piece of code. Following the example of the [Omega theme](http://drupal.org/project/omega "The Omega theme on Drupal.org"), I've started separating my process and preprocess functions into their own files. For example, mytheme_preprocess_node can be placed within a preprocess/node.inc file, and mytheme_process_page can be placed within process/page.inc.
The first step is to use the default mytheme_process() and mytheme_preprocess() functions to utilise my custom function. So within my template.php file:
If you use a lot of process and preprocess functions within your Drupal theme,
then your template.php can get very long and it can become difficult to find a
certain piece of code. Following the example of the
[Omega theme](http://drupal.org/project/omega 'The Omega theme on Drupal.org'),
I've started separating my process and preprocess functions into their own
files. For example, mytheme_preprocess_node can be placed within a
preprocess/node.inc file, and mytheme_process_page can be placed within
process/page.inc.
The first step is to use the default mytheme_process() and mytheme_preprocess()
functions to utilise my custom function. So within my template.php file:
```language-php
<?php
/**
* Implements hook_preprocess().
*
*
* Initialises the mytheme_invoke() function for the preprocess hook.
*/
function mytheme_preprocess(&$variables, $hook) {
@ -26,7 +39,7 @@ function mytheme_preprocess(&$variables, $hook) {
/**
* Implements hook_process().
*
*
* Initialises the mytheme_invoke() function for the process hook.
*/
function mytheme_process(&$variables, $hook) {
@ -50,17 +63,17 @@ Now, to write the `mytheme_invoke()` function:
*
* @param string $hook
* The name of the hook.
*
* @see mytheme_preprocess()
*
* @see mytheme_preprocess()
* @see mytheme_process()
*/
function mytheme_invoke($type, $hook, &$variables) {
global $theme_key;
// The name of the function to look for (e.g. mytheme_process_node).
$function = $theme_key . '_' . $type . '_' . $hook;
// If the function doesn't exist within template.php, look for the
// If the function doesn't exist within template.php, look for the
// appropriate include file.
if (!function_exists($function)) {
// The file to search for (e.g. process/node.inc).
@ -79,4 +92,6 @@ function mytheme_invoke($type, $hook, &$variables) {
}
```
As `mytheme_invoke()` checks to see if the function already exists before searching for checking the include files, I could still add the functions into template.php as normal and this would override any corresponding include file.
As `mytheme_invoke()` checks to see if the function already exists before
searching for checking the include files, I could still add the functions into
template.php as normal and this would override any corresponding include file.