代码不在elgg工作?

时间:2016-10-20 07:25:49

标签: php elgg

    $widget = $vars['entity'];                            
    $container = $widget->getContainerEntity();                         
    $options = eligo_get_display_entities_options($widget);

这是我的owner_block.php文件中不起作用的主线代码。 而且我不知道如何以适当的格式编写代码

elgg.2.2.1 \ MOD \ owner_followers_counter \视图\默认\轮廓\ owner_block.php

此代码无法使用文件名 owner_block.php ,我已插入 owner_followers_counter 插件。当我在owner_block.php文件中插入此代码时,它的输出显示最喜欢的帖子,但有两行不能正常工作,我不知道如何格式化。

$container = $widget->getContainerEntity();

开始,两行不起作用
                 $widget = $vars['entity'];                            
                 $container = $widget->getContainerEntity();    // problem here                     
                 $options =eligo_get_display_entities_options($widget); // and, problem is here

                $options['annotation_names'] = array('likes');

                if (elgg_instanceof($container, 'user') && $widget->my_likes !== 0) {
                  $options['annotation_owner_guids'] = $container->guid;
                }

                if (!elgg_instanceof($container, 'user') && !elgg_instanceof($container, 'group')) {
                  unset($options['container_guids']);
                }


                if ($widget->eligo_sortby == 'mostliked') {
                  $dbprefix = elgg_get_config('dbprefix');
                  $likes_metastring = get_metastring_id('likes');
                  $options['selects'] = array("(SELECT count(distinct l.id) FROM {$dbprefix}annotations l WHERE l.name_id = $likes_metastring AND l.entity_guid = e.guid) AS likes");

                  $options['order_by'] = 'likes ASC';
                  if ($widget->eligo_sortby_dir == 'desc') {
                    $options['order_by'] = 'likes DESC';
                  }
                }

                $content = elgg_list_entities_from_annotations($options);

1 个答案:

答案 0 :(得分:1)

**Ok, I Will Get Answer**

$user = elgg_get_page_owner_entity();
$user_guid = $user->guid;

$options['annotation_names'] = array('likes');
$options['annotation_owner_guids'] = $user_guid;

$dbprefix = elgg_get_config('dbprefix');
$likes_metastring = elgg_get_metastring_id('likes');
$options['selects'] = array("(SELECT count(distinct l.id) FROM {$dbprefix}annotations l WHERE l.name_id = $likes_metastring AND l.entity_guid = e.guid) AS likes");
$options['order_by'] = 'likes DESC';

$content = elgg_list_entities_from_annotations($options);