• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

[bd] Widget Framework

Status
Not open for further replies.

xfrocks

Well-known member
#1
[bd] Widget Framework
People love widgets

[INSTALLATION]
1. Upload files and directories inside `upload` to XenForo's root directory. Select "Merge" for everything if you are asked
2. Import the .xml file using XenForo addon importer
3. Enjoy

[WIDGETS]
Currently, the addon is packed with the following widgets:
1. Clear Sidebar
2. Staff Online Now
3. Members Online Now
4. Forum Statistics
5. Share This Page
6. Users. 2 modes: order by register_date or message_count
7. Threads. 4 modes: New threads, Recent threads, Popular threads or Polls
8. Conditional HTML. Test a PHP expression and display HTML on sidebar
9. Poll (since 1.0). 2 modes: feature poll and recent poll
10. Visitor Panel (since 1.0.6)
11. Recent Status (since 1.0.9)

[GROUPS]
You can group your widgets with tabbed interface. If you happen to have too many widgets, you can use the "random" feature to display only one of them at a time.

[WHY A FRAMEWORK?]
I have seen many people releasing sidebar related addon on xenforo.com. The idea is the same: adding something to a page's sidebar. With the hook, developer can easily modify XenForo's sidebar, no big deal. The problem is each developer prefers a different way to do the job and forums administrator will have difficulties to manage all the stuff on their sidebar. With this framework, that problem is gone. Adminsitrator can manage all the widgets in one place, temporary disable one widget is simple as a click. The order can also be changed (well, not support drag and drop yet, sorry for that).

Also, anyone who wants to develop widget to use with the framework can do it in just a few steps. The framework will take care of everything and developers only need to focus on getting the business done. There are 2 things to do: listen to code event "widget_framework_ready", push your class name in to the array to register your widget renderer. After doing so, you can start coding your renderer by extending the base class "WidgetFramework_WidgetRenderer"
PHP:
class MyWidget_WidgetA extends WidgetFramework_WidgetRenderer {
}
There are some abstract methods you will have to implement to make it work, just dig into the code and figure it out. If you got lost, feel free to contact me: pony@xfrocks.com

One last thing, the framework really care about performance. In perfect conditions, no matter how many widgets you have, the framework only execute 1 additional query. I tried to cache as much as possible. The widget list is stored in XenForo's simple cache system while the rendered widgets are stored with Data Registry. Each renderer doesn't have to handle caching, the framework does that for all widgets. All templates are preloaded with the main page template also. Headache no more ;)
 

Attachments

xfrocks

Well-known member
#2
Version 1.0.7, 17-04-2011
- Added option to hide visitor panel in the Empty widget
- Added option to show polls in the Threads widget
- Added "random" group feature
- Added Visitor Panel widget
- Removed other add-on widgets
- Changed Share widget to Share This Page. It can now be used with any position

Version 1.0.4, 16-03-2011
- Fix Threads widget cache issue
- Added COMPATIBLE GUIDE

Version 1.0.3, 11-02-2011
- Fix tab group invalid characters

Version 1.0.2, 11-02-2011
- Fix Share widget
- Fix Poll widget

Version 1.0.1, 10-02-2011
- Fix problem with "all" position

Version 1.0, 10-02-2011
- Expression for all widgets
- Tabbed wrapper for all widgets
- Now supports "all" position
- Now supports multiple positions (comma separated)
- Default widgets changed:
+ Threads: allow forums inclusion now
+ Forum Stats, Online Staff, Online Users: work across the forums now
- Added new default widgets:
+ [Forum List Only] [GP] Donations (removed in 1.0.7)
+ [Forum List Only] TaigaChat (removed in 1.0.7)
+ xfShout (removed in 1.0.7)
 

Attachments

steven s

Well-known member
#4
>7. Threads. 4 modes: New threads, Recent threads, Popular threads or all of them (tabbed interface)<
Will they be based on permissions?
 

kkm323

Well-known member
#10
this looks great, thought, it would be greater if you can integrate statue update , recent activity
and top poster for the last 30 days
this mod rock thanks
 
R

ragtek

Guest
#13
nice one:)

I also get the idea for a "sidebar widget add-on" yesterday, but nice to see that i don't need to code it:)

You have realy great addons
 
R

ragtek

Guest
#14
holly **** this is really a nice one!!!!wow

I have only two suggestion: use phrases for widget titles and the positioning (conditionals & display order) could be more userfriendly^^ (drag & drop and

Position:
The widget will be displayed on the sidebar when this template is rendered. Not all templates can be used as position, please contact me if your template of choice doesn't work. Popular positions: forum_list (index page), forum_view (forum page), thread_view (thread page).
could be "hard" for the avarage users here;)
)
 
R

ragtek

Guest
#16
One last thing, the framework really care about performance. In perfect conditions, no matter how many widgets you have, the framework only execute 1 additional query. I tried to cache as much as possible. The widget list is stored in XenForo's simple cache system while the rendered widgets are stored with Data Registry. Each renderer doesn't have to handle caching, the framework does that for all widgets. All templates are preloaded with the main page template also. Headache no more

Are you sure that this works?

ATM i have 30 queries on the index page
when i deactive the addon => 25 queries

so there are 5 new queries;)
 

Sador

Well-known member
#17
This looks really interesting. However, will this also take care of other addons which have placed things in the side bar before? If not, could there be a way to somehow be able to manage where they are located as well? Because I really like the idea, but if it only works with side bar things that are specifically created as a widget for your addon, it wouldn't be nearly as useful..
 
R

ragtek

Guest
#19
I'm having problems creating own widgets!

1. i've created my file
PHP:
<?php
class WidgetFramework_WidgetRenderer_Addons extends WidgetFramework_WidgetRenderer_Threads {

    protected function _getConfiguration() {
		return array(
			'name' => 'Addons',
			'options' => array(
				'type' => XenForo_Input::STRING,
				'cutoff' => XenForo_Input::UINT,
				'limit' => XenForo_Input::UINT,
			),
			'useCache' => true,
			'useWrapper' => false,
		);
	}

        protected function _render(array $widget, $templateName, array $params, XenForo_Template_Abstract $renderTemplateObject) {
		$threadModel = XenForo_Model::create('XenForo_Model_Thread');
		$nodeModel = XenForo_Model::create('XenForo_Model_Node');

		$new = $threadModel->getThreads(
				array(
					'forum_ids' => $forumId = XenForo_Application::get('options')->ragtek_AddonForumId,
				)
				,array(
					'order' => 'post_date',
					'orderDirection' => 'desc',
					'join' => XenForo_Model_Thread::FETCH_AVATAR,
					// 'readUserId' => XenForo_Visitor::getUserId(),
					// 'includeForumReadDate' => true,
					'limit' => $widget['options']['limit'],
				)
			);

		$renderTemplateObject->setParam('new', $new);
		$renderTemplateObject->setParam('useTabs', $tabs > 0);

		return $renderTemplateObject->render();
	}
}
2. i'm injecting
PHP:
$renderers[] = 'WidgetFramework_WidgetRenderer_Addons';
at event "widget_framework_ready"

It seems that it's working, because i can create a new add-on widget, when i save it, i don't get an error message, it shows "widget saved successfully" but i can't see it on the widget list and it's also not saved in the xf_widget table.
 

Alluidh

Well-known member
#20
Hi

Only a question. Why are checkboxes on the "List Widgets"-page? You are only able to see the status on this page but your not able to change the status there.
 
Status
Not open for further replies.