I am using the Dukt Follow plugin to return 2 arrays which both hold User objects, I am then using the without filter to remove users from the array which are considered friends. Friends are determined by using the intersect filter on the 2 arrays.
Everything works apart from the second without filter which does not work, and returns objects that are in the friends array.
{# Friends, Followers & Following #}
{% set userFollowing = craft.follow.getFollowing(user.id) %}
{% set userFollowers = craft.follow.getFollowers(user.id) %}
{% set friends = userFollowing|length and userFollowers|length ? userFollowing|intersect(userFollowers) : null %}
{% set following = userFollowing|without(friends) %}
{% set followers = userFollowers|without(friends) %}
Is there an obvious reason why this might not be working? How is best to debug something like this?
I have checked the output of all the arrays and objects and they do appear to hold the data that they should.
Basic data stored in each array:
User Following:
Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn","Craft\\UserModel: shorn"]
User Followers:
Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
Friends:
Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
Following:
Array: {"2":"Craft\\UserModel: shorn"}
Followers:
Array: ["Craft\\UserModel: bencallaway","Craft\\UserModel: davidwearn"]
Full variable output can be accessed here: http://cl.ly/2o292X3O2r0M
without
filter is returning a copy of the array — not modifying the original. In principle, this should work though. You might have something else going on with your data — I would check the values again carefully.