Drupal身体类
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Drupal身体类相关的知识,希望对你有一定的参考价值。
<?php /** * This snippet creates a <body> class and id for each page. * * - Class names are general, applying to a whole section of documents (e.g. admin or ). * - Id names are unique, applying to a single page. */ // Remove any leading and trailing slashes. $uri_path = trim($_SERVER['REQUEST_URI'], '/'); // Split up the remaining URI into an array, using '/' as delimiter. $uri_parts = explode('/', $uri_path); // If the first part is empty, label both id and class 'main'. if ($uri_parts[0] == '') { $body_id = 'main'; $body_class = 'main'; } else { // Construct the id name from the full URI, replacing slashes with dashes. $body_id = str_replace('/','-', $uri_path); // Construct the class name from the first part of the URI only. $body_class = $uri_parts[0]; } /** * Add prefixes to create a kind of protective namepace to prevent possible * conflict with other css selectors. * * - Prefix body ids with "page-"(since we use them to target a specific page). * - Prefix body classes with "section-"(since we use them to target a whole sections). */ $body_id = 'page-'.$body_id; $body_class = 'section-'.$body_class; print "<body class="$body_class" id="$body_id""; print theme('onload_attribute'); print ">"; ?>
以上是关于Drupal身体类的主要内容,如果未能解决你的问题,请参考以下文章