代码在elgg中不起作用? [英] code not working in elgg?

查看:106
本文介绍了代码在elgg中不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这是在我的owner_block.php文件中不起作用的主代码. 而且我不知道如何以正确的格式编写这些行代码

This Is The Main Line Code That Is Not Work In My owner_block.php file. and I don't know how to write that lines code in proper format

elgg.2.2.1 \ mod \ owner_followers_counter \ views \ default \ profile \ owner_block.php

此代码不适用于文件名 owner_block.php ,我在其中插入了 owner_followers_counter 插件.当我将此代码插入owner_block.php文件时,它的输出显示为最喜欢该帖子的内容,但是有两行无法正常工作,并且我不知道如何设置其格式.

this code is not working in file name owner_block.php where I have inserted owner_followers_counter plugin. When I insert this code in my owner_block.php file, it's output is display most liked the post, but there is two line does not work properly, and I don't know how to format that.

$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);

推荐答案

**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);

这篇关于代码在elgg中不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆