Implemented itemCount Support For Custom Tabs

digitalpoint

Well-known member
A simple change to the navigation template would allow an optional item count to be used with custom tabs (it's optional so it would also maintain backward compatibility).

In the navigation template, if this:
Code:
<a href="{$extraTab.href}" class="navLink">{$extraTab.title}</a>
was changed to this:
Code:
<a href="{$extraTab.href}" class="navLink">{$extraTab.title}<xen:if is="{$extraTab.counter}"><strong class="itemCount"><span class="Total">{$extraTab.counter}</span><span class="arrow"></span></strong></xen:if></a>
You could pass a "counter" parameter when building the custom tab and it would look something like so:
Image%202012.03.15%204:01:13%20PM.png
 
Upvote 16
This suggestion has been implemented. Votes are no longer accepted.
I think you can add that without template changes with jquery:

Code:
$("a:contains('{$extraTab.title}')").appends("{$extraTab.counterHTML}");

Not as nice as doing it in HTML, that's for sure.
 
Accompanying this feature should be an API to serve AJAX updates to the count like what is done for alerts and PMs.
While that would be nice, it adds a lot more complexity to things since now you are mucking with the xenforo.js JavaScript, and trying to attach values every time an AJAX request is made. In theory you could do it already now (mostly) by appending the values to any AJAX output, and then have the xenforo.js be a little more generic... like it could look for ajaxData._tabCounter_[DOM ID of tab], parse the DOM ID and fire XenForo.balloonCounterUpdate() against that tab ID with that value.
 
I've done the core change requested here - the subsequent changes should be resuggested if they're still applicable.

Awesome. Just so I got this correct Mike, The ability is now there for add-on creators to implement their own alerts on the custom Tab of their add-ons? Say, if they wanted to have an alert on the resource manager tab?
 
I've done the core change requested here - the subsequent changes should be resuggested if they're still applicable.
Yeah, this one would be a good one, please, Mike:
If you add this feature then I would like to request that this function be changed to accept an array of forumids:

XenForo_Model_Forum::getUnreadThreadCountInForum

This would be useful for my Nodes As Tabs addon.
 
Don't you already get full-blown alerts for anything you watch under the Alerts menu?

I don't think there's an option currently where say a new resource was posted and an alert pops up. I guess we would if we watched the resource in question which I think DD was referring to and someone posted in it or an update was made. Not 100% though with the latter since i don't think i watch any resources.
 
I wouldn't say that this is implemented.

At least it's not working for me.

1. it's only visible if there's a linkTemplate
Rich (BB code):
<xen:if is="{$extraTab.linksTemplate}">
<li class="navTab {$extraTabId} {xen:if $extraTab.selected, 'selected', 'Popup PopupControl PopupClosed'}">
 
<a href="{$extraTab.href}" class="navLink">{$extraTab.title}<xen:if is="{$extraTab.counter}"><strong class="itemCount"><span class="Total">{$extraTab.counter}</span><span class="arrow"></span></strong></xen:if></a>
<a href="{$extraTab.href}" class="SplitCtrl" rel="Menu"></a>
 
<div class="{xen:if {$extraTab.selected}, 'tabLinks', 'Menu JsOnly tabMenu'} {$extraTabId}TabLinks">
<div class="primaryContent menuHeader">
<h3>{$extraTab.title}</h3>
<div class="muted">{xen:phrase quick_links}</div>
</div>
{xen:raw $extraTab.linksTemplate}
</div>
</li>
<xen:else />
<li class="navTab {$extraTabId} {xen:if $extraTab.selected, 'selected', 'PopupClosed'}">
<a href="{$extraTab.href}" class="navLink">{$extraTab.title}</a>
<xen:if is="{$extraTab.selected}"><div class="tabLinks"></div></xen:if>
</li>
</xen:if>

2. if the tab is selected, the itemCount element is misplaced.
 

Attachments

  • b.webp
    b.webp
    3.9 KB · Views: 23
Part 2 of his report has already been fixed. The first bit can be reported as a bug though.
 
super suggestion (y)

Alerts for Resources would be a valuable addition.....

Here's a thread you might be interested in and keep an eye out on since chances are a developer will sooner or later (once item count support is fixed and released) will post with something we can use in the way of an add-on eventually being made. Personally I'd prefer it built into the core but chances are we will see an add-on made before that. :) http://xenforo.com/community/threads/item-count-support-for-rm.48303/

edit: it's well worth getting a discussion/brainstorming thread started (which is why i created it) before so developers know what people are looking for.
 
Here's a thread you might be interested in and keep an eye out on since chances are a developer will sooner or later (one item count support is fixed and released) will post with something we can use in the way of an add-on eventually being made. Personally I'd prefer it built into the core but chances are we will see an add-on made before that. :) http://xenforo.com/community/threads/item-count-support-for-rm.48303/

edit: it's well worth getting a discussion/brainstorming thread started (which is why i created it) before so developers know what people are looking for.

Thanks!
IMHO, this feature should be in the core...... no need to mess around with buggy Addons :cool:
 
Top Bottom