Who is viewing this topic [Deleted]

Fixed forgotten potentional issue where in some cases setParam on controller view may cause issue
How did you fix it? With this code?
PHP:
        if(is_null($users)){
            $users = 0;
        }
It doesn't fix it. You should do something like this:
PHP:
public function actionIndex(ParameterBag $params)
{
    $reply = parent::actionIndex($params);
    
    if (!($reply instanceof \XF\Mvc\Reply\View))
    {
        return $reply;
    }
    
    // your code here
    
    $reply->setParams([
        'users' => $users,
        'userswhoread' => $userswhoread
    ]);
    
    return $reply;
}

Edited table names to follow XenForo Resource Standards rule 11.
Yes, but during the update, you did not drop or rename the old table, so it will now remain in the database as garbage. Also, during uninstalling the add-on, you drop the table with the old name and not the one with the new one.
 
How did you fix it? With this code?
PHP:
        if(is_null($users)){
            $users = 0;
        }
It doesn't fix it. You should do something like this:
PHP:
public function actionIndex(ParameterBag $params)
{
    $reply = parent::actionIndex($params);
   
    if (!($reply instanceof \XF\Mvc\Reply\View))
    {
        return $reply;
    }
   
    // your code here
   
    $reply->setParams([
        'users' => $users,
        'userswhoread' => $userswhoread
    ]);
   
    return $reply;
}


Yes, but during the update, you did not drop or rename the old table, so it will now remain in the database as garbage. Also, during uninstalling the add-on, you drop the table with the old name and not the one with the new one.
I updated the resource a few moments ago. I've forgotten to see this. I was thinking of variable $users if null. And no, it is not controller for replyin to the thread xD :D. It's thread view where i just add 2 widgets to display who currently is viewing a topic and who has read that topic :D.
 
By the way, about the fact that you do not see any problems with displaying the style of the username.
I have an addon that allows users to customize their name colors, it adds a new class to the username. In your addon, only the CSS for the user group will be applied:

1632348514918.webp

So you need to replace this:
HTML:
<a href="{{link('members')}}{{$members.username}}.{{$members.user_id}}" class="username" dir="auto" itemprop="name" data-user-id="{{$members.user_id}}" data-xf-init="member-tooltip"><xf:if is="$members.username_css"><span style="{{$members.username_css}}">{{$members.username}}<xf:else/>{{$members.username}}</span></xf:if></a>
with this:
Code:
<xf:username user="$members" rich="true" />


For the future, it is wrong: {{link('members')}}{{$members.username}}.{{$members.user_id}. You had to do this: {{ link('members', $members) }}.
 
By the way, about the fact that you do not see any problems with displaying the style of the username.
I have an addon that allows users to customize their name colors, it adds a new class to the username. In your addon, only the CSS for the user group will be applied:

View attachment 257634

So you need to replace this:
HTML:
<a href="{{link('members')}}{{$members.username}}.{{$members.user_id}}" class="username" dir="auto" itemprop="name" data-user-id="{{$members.user_id}}" data-xf-init="member-tooltip"><xf:if is="$members.username_css"><span style="{{$members.username_css}}">{{$members.username}}<xf:else/>{{$members.username}}</span></xf:if></a>
with this:
Code:
<xf:username user="$members" rich="true" />


For the future, it is wrong: {{link('members')}}{{$members.username}}.{{$members.user_id}. You had to do this: {{ link('members', $members) }}.
There is nothing wrong with displaying style as described in resource. It's based on user group style.
 
There is nothing wrong with displaying style as described in resource. It's based on user group style.
Nothing wrong? And the fact that my styles are not applied in these blocks? This is just out of the box. And even all styles will not work out of the box, for example, classes for banned users, staff, administrators and moderators are not applied.
However, you should use xf:username so that there are no questions from addon users. And the implementation itself, again, will not allow other add-ons to make any changes to the behavior of the username link.
 
Nothing wrong? And the fact that my styles are not applied in these blocks? This is just out of the box. And even all styles will not work out of the box, for example, classes for banned users, staff, administrators and moderators are not applied.
However, you should use xf:username so that there are no questions from addon users. And the implementation itself, again, will not allow other add-ons to make any changes to the behavior of the username link.
I can't reproduce that. These two blocks are custom created by my addon. Which will display color of user groups.
 
I can't reproduce that. These two blocks are custom created by my addon. Which will display color of user groups.
I am not asking you to reproduce it, I am saying that it is not necessary to do so. You've hard-coded the username display so that no styles other than group styles can be applied to them, and any changes to username display made by other add-ons simply won't work here.
 
I am not asking you to reproduce it, I am saying that it is not necessary to do so. You've hard-coded the username display so that no styles other than group styles can be applied to them, and any changes to username display made by other add-ons simply won't work here.
Will work if you extend the addon ofc.
For widget "Who read this topic" is based on Relationships using magic method which u can make exception, for "Who is currently viewing topic" is used on other principe by making 2 queries (because i'm fetching from Session Activity who is currently viewing topic) and putting them in array user_id, username, username_css obtained from UserGroup entity. Easier for widget Who is currently viewing can't be.
 
Will work if you extend the addon ofc.
Are you joking? I'm showing you that my custom style doesn't apply here.

Here's the HTML of the username, rendered via xf:username:
1632351162778.webp
And from your add-on:
1632351187500.webp

And why it should work if no classes were applied?

Why is it so hard to fix this bug by saying it is not a bug?
 
Are you joking? I'm showing you that my custom style doesn't apply here.

Here's the HTML of the username, rendered via xf:username:
View attachment 257635
And from your add-on:
View attachment 257636

And why it should work if no classes were applied?

Why is it so hard to fix this bug by saying it is not a bug?
By default XenForo has not implemented custom username styling other than by user group. My main idea was to do user color based on his own user group.
 
By default XenForo has not implemented custom username styling other than by user group.
You are not right. Out of the box there is also styling for banned users and it is possible to add styles for staff, admins and moderators.
Since you are developing a public add-on, you should also think about compatibility with other addons. In any case, it's up to you, I pointed out the mistakes.
 
  • Like
Reactions: Xon
You are not right. Out of the box there is also styling for banned users and it is possible to add styles for staff, admins and moderators.
Since you are developing a public add-on, you should also think about compatibility with other addons. In any case, it's up to you, I pointed out the mistakes.
Easiest for widget who is currently viewing a thread can't be. Because they are getting from SessionActivity and in array username_css is imported from his own user group. If you have in table custom column that allow custom styling you can replace with yours.

For second, Who has view this thread this can be easily changed in template modification find at the end when you see block for this widget <xf:if and replace it with your.
 
Try adding rich ="true". This is not mentioned in the documentation, but without it, the styles will not be applied.
Perhaps that <xf:username will render all informations with <a> and closin tag i don't think it's possible without breaking the display of user group styling. If this is case, you can edit the template and make to fit your needs.
 
Perhaps that <xf:username will render all informations with <a> and closin tag i don't think it's possible without breaking the display of user group styling. If this is case, you can edit the template and make to fit your needs.
Nothing should break if everything is correct.
 
Back
Top Bottom