• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.2 Remove "Robots" from Sidebar Members Online Now block?

markku

Well-known member
#1
How can I remove the amount of robots being listed in the sidebar's "Members Online Now" block?

I don't appreciate that it by default spans to two lines now due to this... in 1.1.x there was only amount of members and guests listed and thus it took only one line.

Help please? :)
 

borbole

Well-known member
#2
How can I remove the amount of robots being listed in the sidebar's "Members Online Now" block?

I don't appreciate that it by default spans to two lines now due to this... in 1.1.x there was only amount of members and guests listed and thus it took only one line.

Help please? :)
Find this code at the sidebar_online_users template:

HTML:
<div class="footnote">
    {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}', 'robots={xen:number $onlineUsers.robots}'}
</div>
And replace it with:

HTML:
<div class="footnote">
            {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number $onlineUsers.total}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
        </div>
And save the changes.

Then find the following phrase: online_now_x_members_y_guests_z_robots_a and change the text to:

Code:
Total: {total} (members: {members}, guests: {guests})
Save the changes and you are all set.
 

markku

Well-known member
#3
Thanks a lot!

That works otherwise, but now the Total: is wrong.

e.g. 10 members, 10 guests, 10 robots

It shows up as:

Total: 30 (members: 10, guests: 10)

I suppose removing robots from being added up to Total: would require further hacking?

Probably not worth it...
 

Jeremy

Well-known member
#4
Code:
<div class="footnote">
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number '{xen:calc $onlineUsers.total - $onlineUsers.
robots}'}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
</div>
Untested, but theoretically should work.
 

markku

Well-known member
#5
Code:
<div class="footnote">
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number '{xen:calc $onlineUsers.total - $onlineUsers.
robots}'}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
</div>
Untested, but theoretically should work.
The following error occurred:
The following templates contained errors and were not saved: sidebar_online_users: 1) Line 69: Template syntax error.

Line 69 being...

Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number '{xen:calc $onlineUsers.total - $onlineUsers.robots}'}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
 

Jeremy

Well-known member
#6
My xen:calc, is malformed. If nobody fixes it by the time I get home, I'll be able to work with it to get it to compile correctly.
 

KenSmith

Active member
#7
The variables inside the calc need braces:
Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.total}-{$onlineUsers.robots}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
I also removed the single quotes around the xen:number expression.
 

markku

Well-known member
#8
The variables inside the calc need braces:
Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.total}-{$onlineUsers.robots}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
I also removed the single quotes around the xen:number expression.
This works in a way that it doesn't produce an error, but what I wanted to achieve unfortunately isn't achieved.

Still the Total: is the sum of guests + members + robots... even though I'd like the Total: x to be the sum of members + guests.

That works otherwise, but now the Total: is wrong.

e.g. 10 members, 10 guests, 10 robots

It shows up as:

Total: 30 (members: 10, guests: 10)

I suppose removing robots from being added up to Total: would require further hacking?
 

Jeremy

Well-known member
#9
Try this then:
Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.members}+{$onlineUsers.guests}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
 

markku

Well-known member
#10
Try this then:
Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.members}+{$onlineUsers.guests}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
Nope. The Total: seems to be very stubborn! Still insists on summing it up as members + guests + robots even though the appropriate code in the sidebar_online_users is now this:
Code:
<div class="footnote">
            {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.members}+{$onlineUsers.guests}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
        </div>
I wonder if the Total: just cannot be changed to reflect only members + guests? Could it somehow not be possible? Could @Mike kindly chime in?

I do appreciate you guys trying to help though. It's very nice of you! :)
 

KenSmith

Active member
#11
I can't see any reason this shouldn't work.
Are you certain that you are editing the right template, in the currently selected style?
 

markku

Well-known member
#12
I can't see any reason this shouldn't work.
Are you certain that you are editing the right template, in the currently selected style?
I really am sure it's in the right place. I made sure about it so I wouldn't feel like a fool later :)

Having tried both yours and Jeremy's edit (currently have Jeremy's edit active), the result on my forum right now is like this:
Total: 210 (members: 20, guests: 181)

20 + 181 = 201 so there are probably 9 robots... which shouldn't be included in the Total:, but currently still is.

The whole sidebar_online_user template is referenced below:

Code:
<xen:edithint template="sidebar.css" />

<!-- block: sidebar_online_staff -->
<xen:if hascontent="true">
    <div class="section staffOnline avatarList">
        <div class="secondaryContent">
            <h3>{xen:phrase staff_online_now}</h3>
            <ul>
                <xen:contentcheck>
                    <xen:foreach loop="$onlineUsers.records" value="$user">
                        <xen:if is="{$user.is_staff}">
                            <li>
                                <xen:avatar user="$user" size="s" img="true" />
                                <xen:username user="$user" rich="true" />
                                <div class="userTitle">{xen:helper userTitle, $user}</div>
                            </li>
                        </xen:if>
                    </xen:foreach>
                </xen:contentcheck>
            </ul>
        </div>
    </div>
</xen:if>
<!-- end block: sidebar_online_staff -->

<!-- block: sidebar_online_users -->
<div class="section membersOnline userList">       
    <div class="secondaryContent">
        <h3><a href="{xen:link online}" title="{xen:phrase see_all_online_users}">{xen:phrase members_online_now}</a></h3>
       
        <xen:if is="{$onlineUsers.records}">
       
            <xen:if is="{$visitor.user_id}">
                <xen:if hascontent="true">
                <h4 class="minorHeading"><a href="{xen:link account/following}">{xen:phrase people_you_follow}:</a></h4>
                <ul class="followedOnline">
                    <xen:contentcheck>
                        <xen:foreach loop="$onlineUsers.records" value="$user">
                            <xen:if is="{$user.followed}">
                                <li title="{$user.username}" class="Tooltip"><xen:avatar user="$user" size="s" img="true" class="_plainImage" /></li>
                            </xen:if>
                        </xen:foreach>
                    </xen:contentcheck>
                </ul>
                <h4 class="minorHeading"><a href="{xen:link members}">{xen:phrase members}:</a></h4>
                </xen:if>
            </xen:if>
           
            <ol class="listInline">
                <xen:foreach loop="$onlineUsers.records" value="$user" i="$i">
                    <xen:if is="{$i} <= {$onlineUsers.limit}">
                        <li>
                        <xen:if is="{$user.user_id}">
                            <a href="{xen:link members, $user}"
                                class="username{xen:if '!{$user.visible}', ' invisible'}{xen:if {$user.followed}, ' followed'}">{$user.username}</a><xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        <xen:else />
                            {xen:phrase guest}<xen:if is="{$i} < {$onlineUsers.limit}">,</xen:if>
                        </xen:if>
                        </li>
                    </xen:if>
                </xen:foreach>
                <xen:if is="{$onlineUsers.recordsUnseen}">
                    <li class="moreLink">... <a href="{xen:link online}" title="{xen:phrase see_all_visitors}">{xen:phrase and_x_more, 'count={xen:number $onlineUsers.recordsUnseen}'}</a></li>
                </xen:if>
            </ol>
        </xen:if>
       
        <div class="footnote">
            {xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.members}+{$onlineUsers.guests}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
        </div>
    </div>
</div>
<!-- end block: sidebar_online_users -->
 

KenSmith

Active member
#13
OK, I'm slightly handicapped because I can't test this on a live site, so my "robots" total is always zero.

To test it locally, I just tried this line instead:
Code:
{xen:phrase online_now_x_members_y_guests_z_robots_a, 'total={xen:number {xen:calc '{$onlineUsers.members}+{$onlineUsers.members}'}}', 'members={xen:number $onlineUsers.members}', 'guests={xen:number $onlineUsers.guests}'}
Silly I know. It calculates the "total" as double the number of 'members'. Works here.
With just me logged in, I see: "Total: 2 (members: 1, guests: 0)"

I'm all out of guesses on why you're not seeing the right numbers. I suppose you could try my testing line and see if you get a total of double the members count.
 

markku

Well-known member
#14
Oh my god.

Did I say something about wanting to avoid feeling like a fool?

Since @KenSmith's code didn't do anything (i.e. it didn't add double the members amount to the Total), I tried changing that part of the code to simply say "fjdofsjoer".

It didn't have any effect on the online statistics in the sidebar.

Then I remembered...

I have Widget Framework addon installed, so I presume that has its own online sidebar users widget and I need to find that template and edit it.

So simple explanation.

EDIT:

I edited wf_widget_online_users and now it works!