
В этом сниппете из цикла Theme by pieces о главном меню.
в page.tpl.php:
<?php if ($primary_menu): print $primary_menu; endif; ?>
<?php if ($secondary_menu): print $secondary_menu; endif; ?>В template.php в функции
mytheme_preprocess_page(&$vars, $hook):
<?php
if (!empty($vars['primary_links'])) {
$vars['primary_menu'] = theme('links_primary', $vars['primary_links'], array('class' => 'bookmarks'));
}
?>Для сложной верстки, когда не хватает стандартных тегов ul/li,
например, когда меню имеет круглые края.
В этом случае удобнее включить дополнительный шаблон.
<?php
?>
For example for Secondary links:
_preprocess_page(&$vars, $hook)
<?php
if (!empty($vars['secondary_links'])) {
$vars['secondary_menu'] = theme('links_secondary', $vars['secondary_links'], array('class' => 'static-menu'));
}
?><?php
/**.
* Implementation of hook_theme.
*
* Register custom theme functions.
*/
function renlife_theme() {
return array(
'links_secondary' => array(
'arguments' => array(
'links' => NULL,
'attributes' => array('class' => 'links'),
'settings' => array(
'delimiter' => '',
'leftcab' => NULL,
'rightcab' => NULL,
)
),
'template' => 'links-plain',
)
);
}
?>Для plain меню, когда разметка меню не содержит ul/li,
но содержит разделители между пунктами тип "|",
используем дополнительный шаблон
plain
<?php
/**
* This snippet changes links layout.
*/
$output = '';
if (
count($links) > 0) {
$output .= '<div'. drupal_attributes($attributes) .'>';
// Display the right cap of the 'button bar'.
if (!empty($settings['leftcab'])) {
$output .= $settings['leftcab'];
}
// Build the list of themed links.
$link_list = array();
foreach ($links as $link) {
if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys.
$link_list[] = l($link['title'], $link['href'], $link);
}
else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes
if (empty($link['html'])) {
$link['title'] = check_plain($link['title']);
}
$span_attributes = '';
if (isset($link['attributes'])) {
$span_attributes = drupal_attributes($link['attributes']);
}
$link_list[] = '<span'. $span_attributes .'>'. $link['title'] .'</span>';
}
}
// Add delimiter between the links.
if (!empty($settings['delimiter'])) {
$output .= implode($settings['delimiter'], $link_list);
}
else {
$output .= implode('', $link_list);
}
// Display the right cap of the 'button bar'.
if (!empty($settings['rightcab'])) {
$output .= $settings['rightcab'];
}
$output .= '</div>';
}
print
$output;
?>Это первая заметка из цикла Theme by pieces -
о логотипе, site name и slogan
В template.php в функции
mytheme_preprocess_page(&$vars, $hook)
<?php
// Set variables for the logo and site_name.
if (!empty($vars['logo'])) {
// Return the site_name even when site_name is disabled in theme settings.
$vars['logo_alt_text'] = variable_get('site_name', '');
$vars['site_logo'] = '<a href="'. $vars['front_page'] .'" title="'. t('Home page') .'" rel="home"><img src="'. $vars['logo'] .'" alt="'. $vars['logo_alt_text'] .' '. t('logo') .'" /></a>';
}
?>В page.tpl.php:
<?php if ($site_logo): ?><span id="logo"><?php print $site_logo; ?></span><?php endif; ?>
<?php if ($site_name): ?><span id="site-name"><?php print $site_name; ?></span><?php endif; ?> Если мы хотим вывести CCK поле типа 'дата' (модуль date) в виде календарика, как на иллюстрации, то для этого:
<?php if (!empty($field_date[0]['value'])) {
$date = strtotime($field_date[0]['value']); ?>
<div class="field-field-newsdate">
<div class="mon"><?php print format_date($date, 'custom', 'M'); ?></div>
<div class="day"><?php print format_date($date, 'custom', 'j'); ?></div>
</div>
<?php } ?> .field-field-newsdate {
background:url("images/cal.png") no-repeat scroll center top transparent;
float:right;
font-size:8px;
height:30px;
line-height:13px;
text-align:center;
width:29px;
text-transform:uppercase;
}
.field-field-newsdate .mon {
color:#FDFEE9;
font-weight:bold;
}Подобрать фон для календарика можно здесь - Free Web 2.0 Calendar Icons