Archive for December, 2008

Dec
25
2008

大家圣诞快乐!:)

一年又要过去了,自己成长了很多却没对公司做什么贡献T_T

爸妈继续参加了今年公司组织的父母旅游,公司组织活动和旅游的几天,正好是广州国际设计周,我们有个展位所以我走不开,呜呜呜~还好有城和飞陪爸爸妈妈:)最开心和最有成就感的是,展会完了之后的几天,我带他们去逛了中大本部和珠海校区!^_^

废话少说,上照片:

锦绣中华:布达拉宫的两位大美女:

..Read More»

Tag: , ,
Dec
23
2008

从engadget上看到的,大家来玩玩HD版本的俄罗斯方块:

http://www.ngworks.net/game/tetoris.html

记得自备眼药水:)

本来打算消掉一行的,但因为某块L放错后我放弃了。。囧。。。

Dec
18
2008

当本页面存在父页面时,在sidebar列出父页面下属的所有页面(即列出跟本页面同级的页面),当本页面为父页面时,则列本页的子页面出来,这是CMS最普遍的应用之一,实现方法为(sidebar.php):

  1. <?php if (have_posts()) : ?>
  2. <?php while (have_posts()) : the_post(); ?>
  3.  
  4.     <?php /* Creates a menu for pages beneath the level of the current page - Thanks K2 Theme*/
  5.             if (is_page() and ($notfound != '1')) {
  6.                 $parent_page = $post->ID;
  7.     
  8.                 while($parent_page) {
  9.                     $page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$parent_page'");
  10.                     $parent_page = $page_query->post_parent;
  11.                 }
  12.                 $parent_id = $page_query->ID;
  13.                 $parent_title = $page_query->post_title;
  14.    
  15.                 if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) { ?>
  16.  
  17.             <div class="s_panel">
  18.                 <h2 class="title"><?php echo $parent_title; ?></h2>
  19.                 <ul><?php wp_list_pages('depth=1&sort_column=menu_order&title_li=&child_of='. $parent_id); ?></ul>
  20.             </div>
  21.  
  22.         <?php }?>
  23.    
  24.     <?php } } ?>
  25.    
  26. <?php endwhile; endif; ?>

但是有个问题一直没解决,就是当本页面是很孤独的页面,没有父页面也没有子页面时,怎样让侧边不出现这个s_panel,以前我用两种作法,一是硬挤几个同级页面给它,一是做2个template,带和不带s_panel各一个,都很麻烦,刚突然发现了可以在上述parent_id功能上,再利用wp_list_pages结合echo=0来判断是否要输出,问题就迎刃而解了。真是好晕,整天在CODEX上的wp_list_pages上琢磨,却完全没有看到echo=0!

改后的代码如下:

  1. <?php if (have_posts()) : ?>
  2. <?php while (have_posts()) : the_post(); ?>
  3.  
  4.     <?php /* Creates a menu for pages beneath the level of the current page - Thanks K2 Theme*/
  5.             if (is_page() and ($notfound != '1')) {
  6.                 $parent_page = $post->ID;
  7.     
  8.                 while($parent_page) {
  9.                     $page_query = $wpdb->get_row("SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = '$parent_page'");
  10.                     $parent_page = $page_query->post_parent;
  11.                 }
  12.                 $parent_id = $page_query->ID;
  13.                 $parent_title = $page_query->post_title;
  14.    
  15.                 if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_status != 'attachment'")) { ?>
  16.    
  17.        
  18.     <?php $subpage = wp_list_pages('depth=1&echo=0&child_of='.$parent_id); ?><?php //关键 ?>
  19.         <?php if($subpage) { ?>
  20.             <div class="s_panel">
  21.                 <h2 class="title"><?php echo $parent_title; ?></h2>
  22.                 <ul><?php wp_list_pages('depth=1&sort_column=menu_order&title_li=&child_of='. $parent_id); ?></ul>
  23.             </div>
  24.         <?php }?>
  25.    
  26.     <?php } } ?>
  27. <?php endwhile; endif; ?>

今天顺便把WP升级到2.7了,进入后台却发现侧栏导航条不见了,冷静的思考一下,怀疑是插件lighter-menu导致的,直接在地址栏输入插件页将之停用,马上恢复正常!:)

Tag: , ,