【问题标题】:code not working in elgg?代码在 elgg 中不起作用?
【发布时间】:2017-03-02 01:47:59
【问题描述】:
    $widget = $vars['entity'];                            
    $container = $widget->getContainerEntity();                         
    $options = eligo_get_display_entities_options($widget);

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

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

此代码在我插入 owner_followers_counter 插件的文件名 owner_block.php 中不起作用。当我将此代码插入到我的 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);

【问题讨论】:

  • 我将使用 3 个插件,1.owner_followers_counter,2.Liked_Content,3.au_widget,我将从 like_content 获取此代码并将其放入 owner_block.php,因此它不起作用
  • 我将从 like_content 获取代码插件文件为 elgg.2.2.1\mod\liked_content\views\default\widgets\liked_content\content.php 并将此代码粘贴到 elgg.2.2.1\ mod\profile\views\default\profile\owner_block.php 一些,我所做的改变......现在
  • 我想将小部件内容显示到非小部件视图文件中。但我不知道那个程序。请。帮帮我,给我一些扩展或相关信息。在埃尔格。

标签: php elgg


【解决方案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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-03
    • 1970-01-01
    • 2014-07-27
    相关资源
    最近更新 更多