我想要社交引擎的自定义组插件
所以在application/modules/Group/settings/content.php
中我添加了:
array(
'title' => 'Overall Statistic',
'description' => 'Displays overall statistic of groups on group home page.',
'category' => 'Groups',
'type' => 'widget',
'name' => 'group.overall-statistic',
'defaultParams' => array(
'title' => 'Overall Statistic',
),
),
在组插件的widget文件夹中,我添加了两个文件:Controller.php和Index.php
(看起来像这样:application/modules/Group/widgets/overall-statistic
)
controller.php:
<?php
class Group_Widget_OverallStatisticController extends Engine_Content_Widget_Abstract
{
public function indexAction()
{
$groupTable = Engine_Api::_()->getItemTable('group');
$select = new Zend_Db_Select($groupTable->getAdapter());
$select -> from($groupTable->info('name'), 'COUNT(*) AS count')
-> where('group_id > 0');
$this->view->count_groups = $select->query()->fetchColumn(0);
$albumTable = Engine_Api::_()->getItemTable('advgroup_album');
$select = new Zend_Db_Select($albumTable->getAdapter());
$select->from($albumTable->info('name'), 'COUNT(*) AS count')
-> where('album_id > 0');;
$this->view->count_albums = $select->query()->fetchColumn(0);
$photoTable = Engine_Api::_()->getItemTable('advgroup_photo');
$select = new Zend_Db_Select($photoTable->getAdapter());
$select->from($photoTable->info('name'), 'COUNT(*) AS count')
-> where('photo_id > 0');;
$this->view->count_photos = $select->query()->fetchColumn(0);
$topicTable = Engine_Api::_()->getItemTable('advgroup_topic');
$select = new Zend_Db_Select($topicTable->getAdapter());
$select->from($topicTable->info('name'), 'COUNT(*) AS count')
->where('topic_id > 0');;
$this->view->count_topics = $select->query()->fetchColumn(0);
}
}
index.php:
<ul class = "global_form_box" style="margin-bottom: 15px; padding : 0px 15px 15px 15px;">
<br/>
<div class="statistic_info"> <?php echo $this->translate('Total Groups');?></div>
<div class="statistic_count"> <?php echo $this->count_groups?> </div>
<br/>
<div class="statistic_info"> <?php echo $this->translate('Total Albums');?></div>
<div class="statistic_count"> <?php echo $this->count_albums?> </div>
<br/>
<div class="statistic_info"> <?php echo $this->translate('Total Photos');?></div>
<div class="statistic_count"> <?php echo $this->count_photos?> </div>
<br/>
<div class="statistic_info"> <?php echo $this->translate('Total Topics'); ?></div>
<div class="statistic_count"> <?php echo $this->count_topics?> </div>
</ul>
在面板管理员中,当我想要显示它时添加了小部件但是index.php没有出现在我的网站中..
Controller.php运行良好,因为我添加(在controller.php中)
var_dump($groupTable); die;
我可以在我的网站上看到它
怎么可能?我忘记编辑文件了吗? 谢谢
答案 0 :(得分:1)
您需要创建index.tpl而不是index.php
最好从核心插件中创建此小部件,以避免将来升级。