Forum Replies Created
-
AuthorPosts
-
June 24, 2020 at 10:56 PM in reply to: ✅Would it be possible to access a block name from within a callback/template? #20474
badabingbreda
ParticipantSince I'm unable to edit the previous comment I'll just have to make an edit here:
The change wasn't enough, it was good for rendering frontend, but not in the backend. Reverted that change and simply adding it to the following part (same file) fixes it both front and backend:
private function render_block( $attributes = [], $is_preview = false, $post_id = null ) { $attributes[ 'name' ] = $this->id; $this->enqueue_block_assests(); if ( $this->render_callback ) { call_user_func( $this->render_callback, $attributes, $is_preview, $post_id ); return; } if ( file_exists( $this->render_template ) ) { include $this->render_template; } else { locate_template( $this->render_template, true ); } }June 24, 2020 at 10:48 PM in reply to: ✅Would it be possible to access a block name from within a callback/template? #20473badabingbreda
ParticipantAnh,
this isn't working. No matter what I do, can't get the $attributes['name'] because it's not in the attributes.
Using latest Meta Box AIO plugin.
had to make changes to vendor\meta-box\mb-blocks\src\MetaBox.php
public function render( $attributes = [] ) { $this->set_block_data( $attributes ); $attributes[ 'name' ] = $this->id; ob_start(); $post_id = get_the_ID(); $this->render_block( $attributes, false, $post_id ); return ob_get_clean(); }to manually include name, then it worked.
Can you update the code so this works?
badabingbreda
ParticipantThank you, for some reason I had totally forgotten about those! I can work with this!
badabingbreda
ParticipantThanks Long,
I already looked into the MB Conditional Logic but because the button performs an action that requires the wp_option to already be set that makes it a very confusing experience. The text on the button is "synchronize" and it fetches data from one of several different API's that runs a script to convert it into a CPT, taxonomies and terms.
Maybe you can point me to an action- hook that gets called after setting the wp_option, that I can exploit to reload the page using javascript?
badabingbreda
ParticipantHi,
I think I get it now. I don't want to be that guy that compares this to another popular solution to do this, but maybe a warning that there is already an existing view active/multiple views would be helpful. I don't believe I will be the only one ending up with this question if you don't.
I've simply used
{{ mb.do_action( 'some_custom_action' ) }}as the main view so i can add an infinite number of action-views to it and set the order as I need.
December 6, 2019 at 5:31 PM in reply to: Cannot get rwmb_get_object_fields to work for setting object #17420badabingbreda
ParticipantI'm still getting the same MB version as before, 5.2.3. The code is identical as before, so my guess is you still need to push it to packagist, or am I using the wrong version (dev-trunk)?
badabingbreda
ParticipantActually, no.
I was able to fix it because the post-field now also support request by ajax so I changed the code. The strangest thing is, that on the exact same page, there is still a cloneable group field with the same routine (also select_advanced, pulling products from a custom table) that was and is still working as expected. It is still using the same code as before without any problems... for now.
I've seen you're other post https://support.metabox.io/topic/select_advanced-with-ajax/ suggesting that adding with the sanitize_callback might have fixed it. If I can, I'll test that theory.
badabingbreda
ParticipantThanks Anh, that helped!
badabingbreda
ParticipantHas this changed by any chance? I've implemented this successfully a few months ago on a site that's in development, but I just got a call from my client that it doesn't work any more.
Specifically, when I look in the database, and see that on older posts the metavalue for my key is stored, so it also gets the corresponding value. That indicates to me that that part is still working correctly. What is NOT working is when I create a new post, have it search the matching values that are showing in the select_advanced field and try to save it. It stores all but that meta_key to the database... It doesn't store the value on the select2 field, and doesn't seem to pass it on.
badabingbreda
ParticipantOk, so I'm mildly disappointed that my question didn't get a response but I found the answer myself.
I made an error by omitting the config variable in rwmb_meta, which should have been:
rwmb_meta( 'company_password' , array() , $postid )but it still didn't work with the code provided in the docs.
Changed it to:
if ( wp_check_password( $password , rwmb_meta( 'company_password' , array() , $postid ) ) ) { // code when password checks }Please correct in the docs, I'm assuming it has never worked as described.
August 4, 2019 at 3:15 PM in reply to: ✅Getting post ID from inside the Meta Box Block render_callback #15598badabingbreda
ParticipantLOL, was just about to edit my previous comment that I spotted the change in the docs, but not in the actual source-code.
Thanks for the quick fix. It worked out marvelously!
August 4, 2019 at 2:33 PM in reply to: ✅Getting post ID from inside the Meta Box Block render_callback #15594badabingbreda
ParticipantChanged line 99 in MetaBox.php into:
call_user_func( $this->render_callback, $attributes, $is_preview , $post_id );Adding the $post_id does the trick for me. 🙂
August 1, 2019 at 2:47 PM in reply to: ✅Getting post ID from inside the Meta Box Block render_callback #15542badabingbreda
ParticipantUsing my implementation of your Meta Box Block I can enable users to query other parts of the posts data as well. A very simple example for instance is a custom block that will show the terms of a category on the post. But for that, I will need at least the post ID.
Other things might be author of the post, publish-date, or pulling in other custom field (not block) field-data. That last one seems far fetched but why not if it can be done?
As you said, it works when rendering front-end. But that experience is somewhat off when, while using Gutenberg, I can't get to the post id and use that.
badabingbreda
ParticipantYou're absolutely right, clearing cache worked.
Regarding the removal: Shouldn't I be able to have a group with 0 (zero) iterations?
badabingbreda
ParticipantCame here for this problem, but even with update 1.3.3 it persists.
'name' => 'Order Regels', // Optional 'id' => 'orderregels', 'type' => 'group', 'clone' => true, // Drag and drop clones to reorder them? 'sort_clone' => true, // Sub-fields 'collapsible' => true, // true / false 'save_state' => false, // true / false 'default_state' => 'collapsed', // collapsed / expanded 'add_button' => 'Artikel toevoegen', 'group_title' => array( 'field' => 'artikelid' ),Also, when there's only one item in the group there's no way of removing it. You have to create a new one first because the remove link doesn't show, only the sort drag-handle.
-
AuthorPosts