首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在oxwall中的用户仪表板中显示用户通知

在oxwall中的用户仪表板中显示用户通知
EN

Stack Overflow用户
提问于 2015-02-24 06:39:58
回答 1查看 667关注 0票数 1

我正在定制Oxwall通知插件。

我使用的是Oxwall 1.7.0

我试图在用户的仪表板页面中显示通知。

当前,以“通知”的名称显示在右上栏中的通知。

我发现了哪个文件负责显示内容。

ow_plugins/notifications/classes/console_bridge.php

我在这个文件中注释了下面的代码,以从右上栏隐藏通知。

代码语言:javascript
复制
public function collectItems( BASE_CLASS_ConsoleItemCollector $event )
{
   if ( !OW::getUser()->isAuthenticated() )
   {
      return;
   }
   /* Commented this code to hide the notification. 
   $item = new NOTIFICATIONS_CMP_ConsoleItem(); 
   $event->addItem($item, 3);
   */
}

但是当我们使用下面的代码调用用户仪表板中的组件时,它会给我带来错误。

代码语言:javascript
复制
$widgetService = BOL_ComponentAdminService::getInstance();
$widget = $widgetService->addWidget('NOTIFICATIONS_CMP_ConsoleItem', false);
$widgetPlace = $widgetService->addWidgetToPlace($widget, BOL_ComponentService::PLACE_DASHBOARD);
$widgetService->addWidgetToPosition($widgetPlace, BOL_ComponentService::SECTION_LEFT);

错误截图:

如何在用户仪表板中显示通知?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-03 13:09:42

若要在用户仪表板页面中显示用户通知,请按照Widget构造中的以下代码操作。

代码语言:javascript
复制
$this->service = NOTIFICATIONS_BOL_Service::getInstance();

$userid = OW::getUser()->getId();

$allNotificationCount = $this->service->findNotificationCount($userid); // Get the notifications of currently logged in user

$notifications = $this->service->findNotificationList($userid, time(), null, $allNotificationCount);

$notify_array = array();

$i=0;

foreach ( $notifications as $notification )
{
    if(( $notification->entityType == "groups_wal" && $notification->entityId==$groupid ) || ( $notification->entityType == "status_comment" ) )
    {

        $itemEvent = new OW_Event('notifications.on_item_render', array(
                    'key' => 'notification_' . $notification->id,
                    'entityType' => $notification->entityType,
                    'entityId' => $notification->entityId,
                    'pluginKey' => $notification->pluginKey,
                    'userId' => $notification->userId,
                    'viewed' => (bool) $notification->viewed,
                    'data' => $notification->getData()
                ), $notification->getData());

        OW::getEventManager()->trigger($itemEvent);

        $notify_array[$i] = $itemEvent->getData();

        $i++;

        if ( empty($item) )
        {
            continue;
        }
    }
}

$this->assign('item', $notify_array);

在Oxwall小部件的视图中,添加以下代码

代码语言:javascript
复制
{if !empty($item)}
<div class="ow_dashboard_content">
{foreach from=$item key='key' item='v'}
    {$v}
{/foreach}
</div>
{else}
    <div class="ow_content">No Items</div>
{/if}
<div class="clearfix"></div>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28689624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档