在oxwall的用户仪表板中显示用户通知(Display user notifications in User dashboard in oxwall)
我正在定制Oxwall通知插件。
我正在使用Oxwall 1.7.0
我正在尝试在用户的信息中心页面中显示通知。
目前,通知显示在右上角的栏中,名称为“通知”。
我发现哪个文件负责显示内容。
ow_plugins /通知/类/ console_bridge.php
我在此文件中注释了以下代码,以隐藏右上角的通知。
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); */ }
但是当我们使用下面的代码调用用户仪表板中的组件时,它会给我错误。
$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);
错误截图:
如何在用户仪表板中显示通知?
I am customizing Oxwall notification plugin.
I am using Oxwall 1.7.0
I am trying to display notifications in User's dashboard page.
Currently the notification showing in top right bar with name as "Notifications".
I found out which file is responsible for displaying the content.
ow_plugins/notifications/classes/console_bridge.php
I commented the below code in this file to hide the notification from top right bar.
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); */ }
But when we call the component in user's dashboard using the below code, It gives me error.
$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);
Error Screenshot:
How to display the notifications in user-dashboard?
原文:https://stackoverflow.com/questions/28689624
最满意答案
value.replace("\n\n\n", "\n\n")
片段不能像那样工作。 有时你可以做的最好的事情是启动REPL并尝试声明:>>> value = '\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n \n\n' >>> value.replace('\n\n\n', '\n\n') '\n\n\n\n\n\n \n\n\n\n \n\n \n\n'
您必须多次应用它,直到连续不超过两次:
>>> while '\n\n\n' in value: ... value = value.replace("\n\n\n", "\n\n") >>> value '\n\n \n\n \n\n \n\n'
我没有分析它,但我想这是更有效的使用正则表达式:
>>> value = '\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n \n\n' >>> re.sub('\n\n+', '\n\n', value) '\n\n \n\n \n\n \n\n'
The
value.replace("\n\n\n", "\n\n")
snippet does not work like that. Sometimes the best thing you can do is to fire up the REPL and try the statement:>>> value = '\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n \n\n' >>> value.replace('\n\n\n', '\n\n') '\n\n\n\n\n\n \n\n\n\n \n\n \n\n'
You would have to apply it several times until there is no more than two consecutive breaks:
>>> while '\n\n\n' in value: ... value = value.replace("\n\n\n", "\n\n") >>> value '\n\n \n\n \n\n \n\n'
I've not profiled it but I guess it is more efficient to use a regular expression:
>>> value = '\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n \n\n' >>> re.sub('\n\n+', '\n\n', value) '\n\n \n\n \n\n \n\n'
相关问答
更多-
UILabel检测换行符(UILabel detect line breaks)[2021-08-12]
这里是我的工作,用于检测UILabel内部的换行符 - (int)getLengthForString:(NSString *)str fromFrame:(CGRect)frame withFont:(UIFont *)font { int length = 1; int lastSpace = 1; NSString *cutText = [str substringToIndex:length]; CGSize textSize = [cutText sizeWithF ... -
var app = angular.module("myApp", ['ngSanitize']);str = str.replace(/(?:\r\n|\r|\n)/g, '
'); This will turn all returns into HTML str = str.replace(/(?:\r\n|\r|\n)/g, '
'); In case you wonder what ?: means. It is called a non-capturing group. It means that group of regex within the parentheses w ...在Django视图中用BR标记替换纯文本中的换行符(Replace line breaks in plain text with BR tag in Django views)[2023-11-07]
实际上,如果你将它存储在一个数据库中...那么产生的额外查询将为你的请求响应周期添加更多的开销,而不是通过缓存一些相当有效的Python文本转换的输出来节省。 更好的解决方案是缓存视图。 Django对非常灵活的缓存安排提供了大量支持。 不要成为过早优化的人或加仑 。 特别是这种微小的优化。 您的大多数请求响应周期都花在等待数据库或网络延迟上。 Actually, if you are storing it in a database... then the resulting extra query is ...用CSV替换换行符(replace line breaks in CSV)[2023-06-07]
你可以试试这个: /;"(([^"]*)([\r\n])+([^"]*))+"/im 这将匹配;" delimiters ;"每个换行符之前和之后的文本。第二个匹配将是前一个文本,第四个匹配将是以下文本。 请注意,我已经离开了最后一个';' 如果多行值是行中的最后一行,则确保它仍然匹配。 You could try this: /;"(([^"]*)([\r\n])+([^"]*))+"/im This will match the text before and after every newline ...Django自定义标签 - 用两个换行符替换3个以上的换行符(Django Custom Tag - Replace more than 3 line breaks with two line breaks)[2022-02-23]
value.replace("\n\n\n", "\n\n")片段不能像那样工作。 有时你可以做的最好的事情是启动REPL并尝试声明: >>> value = '\n\n\n\n\n\n\n\n\n \n\n\n\n\n \n\n\n \n\n' >>> value.replace('\n\n\n', '\n\n') '\n\n\n\n\n\n \n\n\n\n \n\n \n\n' 您必须多次应用它,直到连续不超过两次: >>> while '\n\n\n' in value: ... value ...内联换行符?(Inline line breaks?)[2023-06-21]
这似乎提供了一个内联中断的解决方案: http : //codepen.io/pageaffairs/pen/oliyz