Hello all, been struggling with handling the users() collection recently, I can’t seem to return anything other than the username and avatar of a user. When I try to call ->firstName() or any other custom field, or try to run a filterBy(‘role’, ‘xxx’), PHP throws some fatal errors at me.
I’ve seen these two errors come up:
Undefined offset: 2 line 274 code 8 file /kirby/toolkit/lib/collection.php
Call to undefined method Data::read() in /kirby/core/user.php on line 46
Anyone know what’s happening here? Any help would be much, much appreciated, thanks!
Have you recently updated your installation? Looks like there’s something missing …
Last night I tried replacing the kirby and panel folders from both Github, and the starterkit zip located on this website
Still to no avail :\ I can try again! Thanks for the super quick response, Kirby’s support team is something else!!
Make sure to also update the toolkit!
Yep, still same problem :\
I made sure it was the latest kirby, and also made sure to download the toolkit separately and I put it in the kirby folder
Really scratchin’ my head here!
Here’s the code I’m using:
<?php foreach($site->users() as $account): ?>
<?php if( $account->avatar() ): ?>
<img src="<?php echo $account->avatar()->resize(200)->url() ?>">
<?php endif ?>
<p><?php echo $site->user('laciel')->firstName() ?></p>
<?php endforeach ?>
The avatar() function works fine, but practically everything else throws me a fatal error
Thanks for all your help thus far!
Hm, there’s nothing wrong with that code, I just threw it at my test install and everything is fine, apart from the firstName throwing an error because I don’t have a user called ‘laciel’.
Can you test with a fresh starterkit?
What is your environment (Server, PHP version)?
Alright, I’ll try with a fresh starterkit!
And I’m running it on a MAMP server on my home machine, PHP version 5.6.10
I’ll let you know how it goes!
Alright, definitely strange! It works fine on a fresh starterkit. So what could even possibly be causing this issue on my other website? What a strange situation!
It’s strange that you get the “Call to undefined method Data::read()” error, because that means that somehow the Toolkit is not loaded correctly.
Actually, I just figured it out!
It seems that there’s been conflict with this: https://codecanyon.net/item/slider-revolution-responsive-jquery-plugin/2580848
Because after I commented out its “embed.php” file that needed to be included, everything worked as it should!
Any ideas on what I could do to fix those conflicts? It would be nice to be able to use this plugin!
What sort of an embed file is that? I’m a bit surprised that needs more than js and css files?
My bad, it’s for the front-end editor to make the slideshows!