主题化-C-使用tpl模板定制XHTML(node.tpl.php)(视频)
本节介绍使用node.tpl.php来对节点部分的内容做主题化的定制。
相关链接:
- Drupal 6.x核心的node.tpl.php默认可用变量描述 (xDrupal.org译文)
- Theme developer module for Drupal 6 - Screencast (Drupal 6 Devel 主题开发模块视频教程)
node.tpl.php源码
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
<?php print $picture ?>
<?php if (!$page): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="content">
<?php print $content ?>
</div>
<?php if ($terms): ?>
<div class="terms">
<?php print $terms ?>
</div>
<?php endif;?>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
<?php print $picture ?>
<?php if (!$page): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="content">
<?php print $content ?>
</div>
<?php if ($terms): ?>
<div class="terms">
<?php print $terms ?>
</div>
<?php endif;?>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
node-album.tpl.php源码
<?php global $base_url; ?>
<?php if ($teaser): ?>
<?php/*<!-- 摘要页面 -->*/?>
<div class="list albumList<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> ">
<?php print $node->field_photos[0]['view']; ?>
<div class="hide">
<h2>
<em><?php print drupal_substr($node->field_photos[0]['data']['title'], 0, 20); ?>@</em>
<a href="<?php print $base_url . "/" . $node->path ;?>" title="<?php print $node->title ; ?>"><?php print drupal_substr($node->title, 0, 30); ?></a>
</h2>
<p class="count"><?php print $node->links['statistics_counter']['title'] ; ?> <a href="<?php print $base_url . "/" . $node->path . "#comments" ;?>"><span class="comment"><?php print $comment_count; ?>次评论</span></a></p>
<div class="tid"><?php print $terms ?></div>
</div>
</div>
<?php/*<!-- /摘要页面 -->*/?>
<?php endif;?>
<?php if ($page): ?>
<?php/*<!-- 完整节点页面 -->*/?>
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
<?php print $picture ?>
<?php if (!$page): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="content">
<?php if ($node->content['body']['#value']):?>
<div class="node-body">
<?php print $node->content['body']['#value'] ?>
</div>
<?php endif ;?>
<div class="node-photos">
<?php if($node->content['field_photos']['field']['#label_display'] != 'hidden'):?>
<h3 class="field-label"><?php print $node->content['field_photos']['field']['#title'] ;?></h3>
<?php endif;?>
<?php foreach ((array)$node->field_photos as $item) { ?>
<div class="photo-item">
<?php print $item['view'] ?>
<?php if ($item['data']['title']): ?>
<h4 class="hide"><?php print $item['data']['title']?></h4>
<?php endif;?>
</div>
<?php } ?>
</div>
</div>
<?php if ($terms): ?>
<div class="terms">
<?php print $terms ?>
</div>
<?php endif;?>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
<?php/*<!-- /完整节点页面 -->*/?>
<?php endif;?>
<?php if ($teaser): ?>
<?php/*<!-- 摘要页面 -->*/?>
<div class="list albumList<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> ">
<?php print $node->field_photos[0]['view']; ?>
<div class="hide">
<h2>
<em><?php print drupal_substr($node->field_photos[0]['data']['title'], 0, 20); ?>@</em>
<a href="<?php print $base_url . "/" . $node->path ;?>" title="<?php print $node->title ; ?>"><?php print drupal_substr($node->title, 0, 30); ?></a>
</h2>
<p class="count"><?php print $node->links['statistics_counter']['title'] ; ?> <a href="<?php print $base_url . "/" . $node->path . "#comments" ;?>"><span class="comment"><?php print $comment_count; ?>次评论</span></a></p>
<div class="tid"><?php print $terms ?></div>
</div>
</div>
<?php/*<!-- /摘要页面 -->*/?>
<?php endif;?>
<?php if ($page): ?>
<?php/*<!-- 完整节点页面 -->*/?>
<div id="node-<?php print $node->nid; ?>" class="node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> clear-block">
<?php print $picture ?>
<?php if (!$page): ?>
<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="content">
<?php if ($node->content['body']['#value']):?>
<div class="node-body">
<?php print $node->content['body']['#value'] ?>
</div>
<?php endif ;?>
<div class="node-photos">
<?php if($node->content['field_photos']['field']['#label_display'] != 'hidden'):?>
<h3 class="field-label"><?php print $node->content['field_photos']['field']['#title'] ;?></h3>
<?php endif;?>
<?php foreach ((array)$node->field_photos as $item) { ?>
<div class="photo-item">
<?php print $item['view'] ?>
<?php if ($item['data']['title']): ?>
<h4 class="hide"><?php print $item['data']['title']?></h4>
<?php endif;?>
</div>
<?php } ?>
</div>
</div>
<?php if ($terms): ?>
<div class="terms">
<?php print $terms ?>
</div>
<?php endif;?>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
<?php/*<!-- /完整节点页面 -->*/?>
<?php endif;?>
node-blog.tpl.php源码
<?php global $base_url; ?>
<?php if ($teaser): ?>
<?php/*<!-- 摘要页面 -->*/?>
<div class="list blogList<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> ">
<h2 class="title-blog"><a href="<?php print $base_url . "/" . $node->path ?>"><?php print $title ; ?></a></h2>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="node-body">
<?php print $node->content['body']['#value'] ; ?>
<?php if ($terms): ?>
<?php print $terms ?>
<?php endif;?>
</div>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
<?php/*<!-- /摘要页面 -->*/?>
<?php endif;?>
<?php if ($page): ?>
<?php/*<!-- 完整节点页面 -->*/?>
<?php include 'node.tpl.php' ;?>
<?php/*<!-- /完整节点页面 -->*/?>
<?php endif;?>
<?php if ($teaser): ?>
<?php/*<!-- 摘要页面 -->*/?>
<div class="list blogList<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?> ">
<h2 class="title-blog"><a href="<?php print $base_url . "/" . $node->path ?>"><?php print $title ; ?></a></h2>
<?php if ($submitted): ?>
<div class="meta">
<?php print $submitted ?>
</div>
<?php endif; ?>
<div class="node-body">
<?php print $node->content['body']['#value'] ; ?>
<?php if ($terms): ?>
<?php print $terms ?>
<?php endif;?>
</div>
<?php if ($links): ?>
<div class="links">
<?php print $links; ?>
</div>
<?php endif;?>
</div>
<?php/*<!-- /摘要页面 -->*/?>
<?php endif;?>
<?php if ($page): ?>
<?php/*<!-- 完整节点页面 -->*/?>
<?php include 'node.tpl.php' ;?>
<?php/*<!-- /完整节点页面 -->*/?>
<?php endif;?>
page-taxonomy.tpl.php源码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
<script type="text/javascript"><?php /* Needed to avoid Flash of Unstyled Content in IE */ ?> </script>
</head>
<body class="root <?php print $body_classes; ?> scroller">
<div id="wrap">
<div id="header">
<div id="logo-title">
<?php if (!empty($logo)): ?>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
</a>
<?php endif; ?>
<?php if (!empty($site_name)): ?>
<h2 id="site-name">
<a href="<?php print $front_page ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
</h2>
<?php endif; ?>
</div> <!-- /logo-title -->
<?php if (!empty($search_box)): ?>
<div id="search-box"><?php print $search_box; ?></div>
<?php endif; ?>
<?php if (!empty($header)): ?>
<div id="header-region">
<?php print $header; ?>
</div>
<?php endif; ?>
<?php if (!empty($breadcrumb)): ?><div id="breadcrumb"><?php print $breadcrumb; ?></div><?php endif; ?>
</div> <!-- /header -->
<div id="sidebar">
<div id="navigation" class="menu <?php if (!empty($primary_links)) { print "withprimary"; } if (!empty($secondary_links)) { print " withsecondary"; } ?> ">
<?php if (!empty($primary_links)): ?>
<div id="primary" class="clear-block">
<?php print theme('links', $primary_links, array('class' => 'primary-links')); ?>
</div>
<?php endif; ?>
<?php if (!empty($secondary_links)): ?>
<div id="secondary" class="clear-block">
<?php print theme('links', $secondary_links, array('class' => 'links secondary-links')); ?>
</div>
<?php endif; ?>
</div> <!-- /navigation -->
<?php print $sidebar; ?>
</div> <!-- /sidebar -->
<div id="contentBox">
<?php if (!empty($title)): ?>
<h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
<div id="contentInner">
<?php if (!empty($mission)): ?>
<div id="mission"><?php print $mission; ?></div>
<?php endif; ?>
<div id="content">
<?php if (!empty($tabs)): ?>
<div class="tabs"><?php print $tabs; ?></div>
<?php endif; ?>
<?php if (!empty($messages)): print $messages; endif; ?>
<?php if (!empty($help)): print $help; endif; ?>
<div id="content-content" class="clear-block">
<?php print $content; ?>
</div> <!-- /content-content -->
<?php print $feed_icons; ?>
</div> <!-- /content -->
</div>
</div> <!-- /contentInner /contentBox -->
</div>
<div id="footer">
<?php print $footer_message; ?>
<?php if (!empty($footer)): print $footer; endif; ?>
</div> <!-- /footer -->
<?php print $closure; ?>
</body>
</html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
<head>
<?php print $head; ?>
<title><?php print $head_title; ?></title>
<?php print $styles; ?>
<?php print $scripts; ?>
<script type="text/javascript"><?php /* Needed to avoid Flash of Unstyled Content in IE */ ?> </script>
</head>
<body class="root <?php print $body_classes; ?> scroller">
<div id="wrap">
<div id="header">
<div id="logo-title">
<?php if (!empty($logo)): ?>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
</a>
<?php endif; ?>
<?php if (!empty($site_name)): ?>
<h2 id="site-name">
<a href="<?php print $front_page ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
</h2>
<?php endif; ?>
</div> <!-- /logo-title -->
<?php if (!empty($search_box)): ?>
<div id="search-box"><?php print $search_box; ?></div>
<?php endif; ?>
<?php if (!empty($header)): ?>
<div id="header-region">
<?php print $header; ?>
</div>
<?php endif; ?>
<?php if (!empty($breadcrumb)): ?><div id="breadcrumb"><?php print $breadcrumb; ?></div><?php endif; ?>
</div> <!-- /header -->
<div id="sidebar">
<div id="navigation" class="menu <?php if (!empty($primary_links)) { print "withprimary"; } if (!empty($secondary_links)) { print " withsecondary"; } ?> ">
<?php if (!empty($primary_links)): ?>
<div id="primary" class="clear-block">
<?php print theme('links', $primary_links, array('class' => 'primary-links')); ?>
</div>
<?php endif; ?>
<?php if (!empty($secondary_links)): ?>
<div id="secondary" class="clear-block">
<?php print theme('links', $secondary_links, array('class' => 'links secondary-links')); ?>
</div>
<?php endif; ?>
</div> <!-- /navigation -->
<?php print $sidebar; ?>
</div> <!-- /sidebar -->
<div id="contentBox">
<?php if (!empty($title)): ?>
<h1 class="title" id="page-title"><?php print $title; ?></h1>
<?php endif; ?>
<div id="contentInner">
<?php if (!empty($mission)): ?>
<div id="mission"><?php print $mission; ?></div>
<?php endif; ?>
<div id="content">
<?php if (!empty($tabs)): ?>
<div class="tabs"><?php print $tabs; ?></div>
<?php endif; ?>
<?php if (!empty($messages)): print $messages; endif; ?>
<?php if (!empty($help)): print $help; endif; ?>
<div id="content-content" class="clear-block">
<?php print $content; ?>
</div> <!-- /content-content -->
<?php print $feed_icons; ?>
</div> <!-- /content -->
</div>
</div> <!-- /contentInner /contentBox -->
</div>
<div id="footer">
<?php print $footer_message; ?>
<?php if (!empty($footer)): print $footer; endif; ?>
</div> <!-- /footer -->
<?php print $closure; ?>
</body>
</html>
- 适于打印版本
- 10197 次点击








呵呵 网站很漂亮mortgage calculator
呵呵 网站很漂亮mortgage calculator
找不到你的联系方式,问题发在这里吧
我看到你页头的图片slide效果很不错,我也用view-slideshow作了一个,但是,我的轮换是缩略图来的,想换成小圆点(你的是小方块),不知道你是怎么做的呢?
盼回复,谢谢
我没用view-slideshow,只是改样式的话修改cs
我没用view-slideshow,只是改样式的话修改css即可。
我的方法是建个block,里面放图片,然后自己写下jquery。你可以用firebug查看下,js源码里也有注释,可以看看。
ps.这儿有个留言本,其他讨论可以发在这儿:) http://xdrupal.org/guestbook
谢谢你的回复:)
谢谢你的回复:)
谢谢你的回复:)
谢谢你的回复:)
发表新评论