Drupal 7 开发内部培训资料, 分头诗人

我查不出为嘛不出分页器和评论框?直接上码

赞成!
0
否决!

我参照诗人的demo写了这个例子,但是不显示分页器和评论框?评论框要另外写代码加入吗?请指点一下,谢谢了。

function og_views_callback_page() { 
	$output = '';
    $query = db_select('node','n')->extend('PagerDefault');
    $query->leftJoin('field_data_body', 'b', 'n.nid = b.entity_id');
    $query->fields('n',array('nid','title','created'))->fields('b',array('body_summary'));
    $query->condition('n.status', 1)
        ->condition('n.type', 'group')
        ->limit(1);
    $query->orderBy('n.created', 'DESC');
    $objects = $query->execute()->fetchAll();
    $rows = array();
    foreach ($objects as $key=>$object) {
        $row = array();
        $row['gid'] = $object -> nid;
        $row['title'] = l($object -> title, 'groups/'.$object ->nid);
        $row['description'] = $object->body_summary;
        $row['created'] = $object -> created;
        $rows[] = $row;
    }
    $output .= theme ( 'pager' );
    $output .= theme('grouds', array('rows' => $rows));
    $output .= theme ( 'pager' );
    return $output;
}

tpl文件:

<ul>
<?php foreach($rows as $data){?>
<li class="list">
		<div class="title"><?php print $data['title']?></div>
  <?php print $data['description']?>
  <div class="created"><?php print $data['created']?></div>
	</li>
<?php }?>
</ul>

Module文件

function og_views_menu() {
	$items ['groups'] = array (
			'title' => '小组列表',
			'description' => '小组列表',
			'page callback' => 'og_views_callback_page',
			'file' => 'og_views.anyone.inc',
			'access callback' => TRUE,
	);
	$items ['groups/%'] = array (
			'title' => '小组内容',
			'description' => '小组详细内容',
			'page callback' => 'og_views_list_callback_page',
			'page arguments' => array (1),
			'file' => 'og_views.anyone.inc',
			'access callback' => TRUE,
	);
	$items ['groups/content/%'] = array (
			'title' => '组内内空',
			'description' => '小组详细内容',
			'page callback' => 'og_views_content_callback_page',
			'page arguments' => array (2),
			'file' => 'og_views.anyone.inc',
			'access callback' => TRUE,
	);
	return $items;
}

function og_views_theme() {
	return array (
			'grouds' => array (
					'template' => 'grouds',
					'variables' => array ()
			),
			'grouds_view' => array (
					'template' => 'grouds_view',
					'variables' => array ()
			),
	);
}

4 个回答

赞成!
0
否决!

评论框是要自己写,这个只是实现列表了。

赞成!
0
否决!

评论框不是有自带的吗?这个又咋写,一头雾水。

赞成!
0
否决!

这是你自己做的列表页,你得重写

赞成!
0
否决!

不知道怎么重写,没有思路,没有头绪。请指点一二。