SyTry
Well-known member
Hello,
I make an add-on and I have a widget with most followers (top 5) but it won't work :

I use this in my template :
	
	
	
		
This in my XF\Widget :
	
	
	
		
I have this in my XF\Entity :
	
	
	
		
And this in my Setup.php :
	
	
	
		
Do you have an idea why my widget don't work ? Maybe my $users variable in XF\Widget
More :
Regards, SyTry
				
			I make an add-on and I have a widget with most followers (top 5) but it won't work :

I use this in my template :
		HTML:
	
	<xf:foreach loop="$users" value="$users">
    {$user.sc_most_followers|number}
</xf:foreach>
	This in my XF\Widget :
		PHP:
	
	    public function render()
    {
        $finder = \XF::finder('XF:User');
        $users = $finder->where('sc_user_follow', '>', 0)
            ->where('is_banned', false)
            ->order('sc_user_follow', 'DESC');
        $option = \XF::options();
        $viewParams = [
            'enable' => $option->scMostFollowersEnable,
            'followersLimit' => $option->followersLimit,
            'users' => $users
        ];
        return $this->renderer('sc_mostFollowersWidget', $viewParams);
    }
	I have this in my XF\Entity :
		PHP:
	
	    public static function getStructure(Structure $structure)
    {
        $structure = parent::getStructure($structure);
        $structure->columns['sc_user_follow'] = ['type' => self::UINT, 'default' => 0, 'forced' => true, 'changeLog' => false];
        return $structure;
    }
	And this in my Setup.php :
		PHP:
	
	    public function installStep1()
    {
        $sm = $this->schemaManager();
        $sm->alterTable('xf_user', function(Alter $table)
        {
            $table->addColumn('sc_user_follow', 'int')->setDefault(0);
            $table->addKey('sc_user_follow', 'most_followers');
        });
    }
	Do you have an idea why my widget don't work ? Maybe my $users variable in XF\Widget
More :
- https://xenforo.com/community/threads/update-sql-column-with-listener-php.159172/
 - https://xenforo.com/community/threads/how-to-update-my-member-statistics.158890/
 
Regards, SyTry

