没错,这就是Drupal圣经“Drupal专业开发指南”中 "Working with nodes" 一章所介绍的范例模块-joke。
文件见附件。
注意:程序中注释的一部分有关于punchline的验证,因为觉得不需要...所以就注释了。
还有就是 hook_theme 部分,因为觉得不如在 "node-joke.tpl.php" 中写的效果来得好,所以也先注释了,那么就要求大家建一个 "node-joke.tpl.php",并将以下代码加到 <?php print $content; ?> 之后。
<?php if($page): ?>
<fieldset class="collapsible collapsed">
<legend>Punchline</legend>
<div class="form-item">
<label><?php if(isset($node->punchline)) {print check_markup($node->punchline);} ?></label>
<label><?php if(isset($node->guffaw)) {print $node->guffaw;} ?></label>
</div>
</fieldset>
<?php endif; ?>接下来还要去 "page.tpl.php" 里硬编码加载一个js文件,代码如下:
<script type="text/javascript" src="<?php print $base_path.'misc/collapse.js'; ?>"></script>OK啦,启用之,就可以在你的站点发布笑话啦!
实际效果预览请见 www.xiaoker8.com 中的笑话部分,谢谢!
- Admin's blog
- 428 reads
Comments
Post new comment