break up repeatable record groups into sections?
-
Some of my lists are getting long to load. While I know I am loading the data directly, that would continue to be no problem, if I could break up the record set into sections like the custom post do.
Such as in this screen grab: https://snag.gy/njsJpF.jpg
Is there a way in CMB2 to put navigation in place for each repeatable record set?
-
This topic was modified 6 years, 10 months ago by
dkurth.
-
This topic was modified 6 years, 10 months ago by
Jan Dembowski. Reason: De-capped topic title, don't yell please
-
This topic was modified 6 years, 10 months ago by
-
Anything like this would be a custom solution, since I am quite sure we don’t have that detail built in, as-is.
ok, this is how it could be done, if you can tell me where I would “add a button” for the group
presently a repeatable group assignment looks like this:
$group_field_id = $cmb->add_field( array( 'id' => 'MMDListsRecord', 'type' => 'group', 'description' => __( 'Individual Directory Listings', 'mmd' ), 'options' => array( 'group_title' => __( 'Record {#}', 'mmd' ), // since version 1.1.4, {#} gets replaced by row number 'add_button' => __( 'Add Another Record', 'mmd' ), 'remove_button' => __( 'Remove Record', 'mmd' ), 'sortable' => true, 'closed' => true, ), 'after_group' => 'mmdlist_add_js_for_repeatable_titles', ) );What I would like to do is add 2 buttons like this:
$group_field_id = $cmb->add_field( array( 'id' => 'MMDListsRecord', 'type' => 'group', 'description' => __( 'Individual Directory Listings', 'mmd' ), 'options' => array( 'group_title' => __( 'Record {#}', 'mmd' ), // since version 1.1.4, {#} gets replaced by row number 'add_button' => __( 'Add Another Record', 'mmd' ), 'prev_button' => __( 'Previous Records', 'mmd' ), <===== **** 'next_button' => __( 'Next Records', 'mmd' ), <===== **** 'remove_button' => __( 'Remove Record', 'mmd' ), 'sortable' => true, 'closed' => true, ), 'after_group' => 'mmdlist_add_js_for_repeatable_titles', ) );This way I can only load say 10 records at a time and thus save the massive amount of browser memory and more importantly the SLOWWWWWWW on the backend. Yes, it is a LOT of data I am pushing around. This would solve the problem.
It appears to be in CMB2.php as:
if ( $field_group->args( 'repeatable' ) ) { echo '<div class="cmb-row"><div class="cmb-td"><p class="cmb-add-row"><button type="button" data-selector="', esc_attr( $field_group->id() ), '_repeat" data-grouptitle="', esc_attr( $field_group->options( 'group_title' ) ), '" class="cmb-add-group-row button-secondary">', $field_group->options( 'add_button' ), '</button></p></div></div>'; } echo '</div></div></div>'; $field_group->peform_param_callback( 'after_group' ); return $field_group; }If this is true, and I add the button there, can you tell me where the “buttons” are processed. Obviously it is another Javascript thing. And one would need a call back to indicate the button has been clicked on, in order to load the next data set.
Looking at that same file, I’m seeing this:
if ( empty( $field['render_row_cb'] ) ) { $field['render_row_cb'] = array( $this, 'render_group_callback' ); }I point this out because the spot you highlight above is in the
render_group_callbackfunction. So, if you specify a customrender_row_cbfunction/callback, you can safely override the spot in question. For ease and some level of compatibility, I’d recommend copyingrender_group_callbackas is into your own function, but then modify as you need afterwards.ok, interesting suggestion. I can give that a go.
That was a great idea…that did not pan out. that particular call back only changes how the individual row is called and does not add another button to the group.
I need to expand the capabilities of the options parameter. This is my present call:
$group_field_id = $cmb->add_field( array( 'id' => 'MMDListsRecord', 'type' => 'group', 'description' => __( 'Individual Directory Listings', 'mmd' ), 'options' => array( 'group_title' => __( 'Record {#}', 'mmd' ), // since version 1.1.4, {#} gets replaced by row number 'add_button' => __( 'Add Another Record', 'mmd' ), 'remove_button' => __( 'Remove Record', 'mmd' ), 'sortable' => true, 'closed' => true, ), 'after_group' => 'mmdlist_add_js_for_repeatable_titles', 'render_row_cb' => 'mmd_render_group_callback', ) );-
This reply was modified 6 years, 10 months ago by
dkurth.
unless I am totally missing something…
Well, you need to add it. That’s all on you. I recommended copy/pasting to retain all what already exists, and then you add your own and tie into the new markup as needed for your current tasks. Just defining and copy/pasting alone isn’t going to add it.
I tried adding just simple text to the field area..that is what confused me, since nothing would display..simple
echo "test message";Right under the button..nada.
Are you certain your callback is being called and triggered?
I can put a debug statement in it to test. But it is connected to the callback hook and i have it another name.
One thing I’ve noticed at times is that even though I try to echo out a simple string, when viewing in the browser it doesn’t immediately show, but when I do a view-source check, it is indeed there. Depends on exactly where in the html markup structure the code is set to echo at.
found a way to do it using separate custom posts.
Awesomesauce.
-
This reply was modified 6 years, 10 months ago by
The topic ‘break up repeatable record groups into sections?’ is closed to new replies.