template_page_suggestions

Versions
7
template_page_suggestions($args, $suggestion)

Generate an array of page template suggestions.

Parameters

$args An array of path arguments, such as from function arg().

Return value

An array of suggested template files.

Code

includes/theme.inc, line 2376

<?php
function template_page_suggestions($args, $suggestion) {

  // Build a list of suggested template files and body classes in order of
  // specificity. One suggestion is made for every element of the current path,
  // though numeric elements are not carried to subsequent suggestions. For
  // example, http://www.example.com/node/1/edit would result in the following
  // suggestions and body classes:
  //
  // page-node-edit.tpl.php  page-node-edit
  // page-node-1.tpl.php     page-node-1
  // page-node.tpl.php       page-node
  // page.tpl.php

  $suggestions = array();
  foreach ($args as $arg) {
    // Remove slashes or null per SA-CORE-2009-003.
    $arg = str_replace(array("/", "\\", "\0"), '', $arg);
    // The percent acts as a wildcard for numeric arguments since
    // asterisks are not valid filename characters on many filesystems.
    if (is_numeric($arg)) {
      $suggestions[] = $suggestion . '-%';
    }
    $suggestions[] = $suggestion . '-' . $arg;
    if (!is_numeric($arg)) {
      $suggestion .= '-' . $arg;
    }
  }
  if (drupal_is_front_page()) {
    $suggestions[] = $suggestion . '-front';
  }

  return $suggestions;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.