WordPress.org

Forums

  1. adamwalter
    Member
    Posted 1 year ago #

    It would be great to have the option of rows being collapsed by default. Thanks for the great plugin.

    http://wordpress.org/plugins/advanced-custom-field-repeater-collapser/

  2. MRWweb
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for the suggestion. Can you say a bit more about the use case for such an option? This is the first time I've heard a feature like this suggested.

    If it were to be added, how would it be set? How would it work when there are no repeater instances yet?

  3. adamwalter
    Member
    Posted 1 year ago #

    Sometimes when I have multiple repeaters on a page (in addition to other fields and metaboxes), each with a good number of rows, it can make for a very long, visually intimidating page for my clients. Finding the right field can be harder. It's not really a major issue, just a small tweak/idea.

  4. raydale
    Member
    Posted 1 year ago #

    I would like to second this request. As adamwalter mentions it would be great to be able to specify that a repeater field (or any other field) defaults to 'collapsed' initially when loading the page. Collapsed groups of repeater fields are also much easier to drag and re-order.

  5. MRWweb
    Member
    Plugin Author

    Posted 1 year ago #

    Are you both thinking that this would be a per-repeater setting?

  6. adamwalter
    Member
    Posted 1 year ago #

    It could be. But something as simple as a global option "Always collapsed / Always expanded" would be helpful.

  7. Paul
    Member
    Posted 1 year ago #

    I would like to throw in my vote for this feature - and add that it would be very useful to be able to open / close individual rows. Collapsing them all makes it easier to reorder them, but while they're collapsed it would be really nice to be able to open 1 row in order to edit it without opening all the rows an scrolling.

  8. rortha
    Member
    Posted 1 year ago #

    i wanna throw in a vote for this as well.

  9. Eric McNiece
    Member
    Posted 1 year ago #

    +1!

  10. Maki_BM
    Member
    Posted 1 year ago #

    Hey guys
    as a fast solution I added this line at the end in original plugin .js file:

    $('.field-repeater-toggle').click();

    Maybe not realy nice but it helps me to toggle / collapse all repeater fields on load of the edit page. Should be as this in default mode, otherwise the plugin doesn't make sense for me - keep all expanded as it would be without plugin. Helping with collapsing just for the moment, until I save isn't great help when it comes to keeping files organised.

    Great plugin though, i just reworked it a little to fit my needs and make me feel more comfortable

  11. simplethemes
    Member
    Posted 1 year ago #

    +1 here as well.

    In the meantime, I've edited field-layout.php line #7:
    (added data-toggle="closed")
    <div class="layout" data-layout="<?php echo $layout['name']; ?>" data-toggle="closed">

    and further down on line #26:
    (added style="display:none")
    <table class="widefat acf-input-table <?php if( $layout['display'] == 'row' ): ?>row_layout<?php endif; ?>" style="display:none">

  12. simplethemes
    Member
    Posted 1 year ago #

    Correction/Follow-up to the above.

    In field layout.php:

    global $pagenow;
    if($pagenow == "post-new.php") {
    	$state = 'open';
    	$display = 'block';
    } elseif ($pagenow == "post.php") {
    	$state = 'closed';
    	$display = 'none';
    }

    Line #7:
    <div class="layout" data-layout="<?php echo $layout['name']; ?>" data-toggle="<?php echo $state;?>">

    Line #26:
    <table class="widefat acf-input-table <?php if( $layout['display'] == 'row' ): ?>row_layout<?php endif; ?>" style="display:<?php echo $display;?>">

    When adding new fields/rows, they become collapsed by default. Typically the user wants to edit right away. To alleviate this, I modified input.js as wel beginning around line #262:

    (See lines notated with "+Added")

    // vars
    var new_id = acf.helpers.uniqid(),
    	new_field_html = this.$el.find('> .clones > .layout[data-layout="' + layout + '"]').html().replace(/(=["]*[\w-\[\]]*?)(acfcloneindex)/g, '$1' + new_id),
    	// +Added data-toggle=open to prevent the need for double-click
    	new_field = $('<div class="layout" data-toggle="open" data-layout="' + layout + '"></div>').append( new_field_html );
    
    // hide no values message
    this.$el.children('.no_value_message').hide();
    
    // +Added show_new_field function to alter the field we hid in field-layout.php
    function show_new_field (new_field) {
    	new_field.find('.acf-input-table').css("display", "block").html;
    	return new_field;
    }
    
    // add row
    if( $before )
    {
    	// +Added show_new_field
    	$before.before( show_new_field(new_field) );
    }
    else
    {
    	// +Added show_new_field
    	this.$values.append( show_new_field(new_field) );
    }
  13. Lyndon Roeller
    Member
    Posted 1 year ago #

    I think this would be a very useful feature as well.

    +1

  14. JulienMelissas
    Member
    Posted 11 months ago #

    Not sure if this helps anyone but I wrote a super quick plugin (can't guarantee it will work on your site but it's working for mine) that should solve this issue. You need to have the Advanced Custom Fields Repeater & Flexible Content Fields Collapser plugin installed of course...

    Here's the link to the GitHub repo: https://github.com/JulienMelissas/acf-collapser-collapse-default you should be able to just download the zip file and upload it to your site.

  15. MRWweb
    Member
    Plugin Author

    Posted 11 months ago #

    Thanks for sharing this, @JulienMelissas. I'm looking forward to trying it out!

  16. Lyndon Roeller
    Member
    Posted 11 months ago #

    I can attest to the fact @JulienMelissas' stop-gap plugin works great. Thanks Julien!

    @mrwweb - looking forward to you making that plugin obsolete ; )

  17. MRWweb
    Member
    Plugin Author

    Posted 11 months ago #

    Thanks again to everyone who's weighed in on this. I've opened a ticket on Github to discuss this feature. I have some questions about the correct implementation that I could use some 2nd opinions on.

  18. JulienMelissas
    Member
    Posted 11 months ago #

    Hey mrwweb your link to the ticket on GitHub isn't correct, but no worries, here's the link for folks who might be browsing this thread: https://github.com/mrwweb/ACF-Repeater-Collapser/issues/17

  19. MRWweb
    Member
    Plugin Author

    Posted 11 months ago #

    :/

    Thanks, @julienmelissas!

  20. Craig Bilski
    Member
    Posted 10 months ago #

    +1 for the idea.

    Thanks for the temp fix @JulienMelissas

    In my opinion, could you make the expand/collapse state just save its state each time you hit the update button. Much like a metabox does when you expanded/collapse it.

    If you collapse a repeaters rows and hit update, when it reloads or you revisit the post it would be collapsed.

    Then obviously if you leave it expanded and you hit update, when it reloads or you revisit the post it would be expanded.

    It would be nice to be able to force a certain state as well if you wish - "Always collapsed / Always expanded" as @adamwalter mentioned

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields Repeater & Flexible Content Fields Collapser
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.