2

EE 2.5.5 PLaya 4.4.1 Zoo Visitor 1.3.23

On this site I have members who can edit their profile and select divisions that they belong to (playa). On the front end I can easily limit the display of their profile to only 4 divisions - :)

However on the divisions section of the site - Each division lists all members of that division using exp:playa:parents. The issue is how do I limit it so that a member only appears in the first 4 divisions that they have selected? As it stands I have a test member who is in 10 divisions and they appear in all divisions, however on their member profile only the first 4 divisions are displayed.

Ideally when setting up the playa field and selecting Allow multiple selections I could limit the number of selections but that doesn't appear to be possible.

1
  • 3
    update - On Twitter Brandon Kelley has said he will add this to the next version of Playa. – CreateSean May 8 '13 at 17:14
1

Could you simply have 4 playa fields limited to a single selection each?

1

looks like this options is still not in Playa.

Solution:

*/themes/third_party/playa/scripts/droppanes.js*

replace

var selectItems = function($items) {

with

var selectItems = function($items) {

    obj.limit = $items.parents("label:first").data('limit');
    obj.totalSelect = obj.selectionsSelect.$items.length + 1;

    if (obj.totalSelect > obj.limit) {
        obj.optionsSelect.deselectAll(true);
        return false;
    }

SafeCracker/Zoo Visitor template code (data-limit is how many options can user choose)

       <label class="input" data-limit="3">
                {field:playa_field}         
       </label>
0

Doing this without building a custom add-on will probably be quite tricky. The only way I can think of is by using a Matrix field limited to 4 rows, with a single-select Playa field in one of the columns. Not a particularly great experience for editing your profile, but it would work.

Edit to add: the upside would be that you could store extra data against each selection very easily, should the site's requirements ever grow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.