Drupal专业开发指南-Working with nodes-范例模块-joke!

-- Submitted by Admin on Fri, 06/11/2010 - 22:28

没错,这就是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 中的笑话部分,谢谢! 

PreviewAttachmentSize
joke.rar2.03 KB

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Allowed HTML tags: <a> <em> <strong> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <img> <ebmed>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
10 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.