I created a custom block, and I faced the issue I've never faced with before. After saving the block and realoding the page, I can see the block disabled and with a warning
This block contains unexpected or invalid content.
And in the console I can see this:
Block validation: Block validation failed
Content generated by 'save' function:
{here is a layout without any value from attributes}
Content retrieved from post body:
{here is a layout with all the data}
So when I log the attributes inside save function they are empty, and WP marks as an error, when the content from the save function does not match to the content posted to the server. Does anyone have any ideas?
When registering a block in JS I forgot to add attributes with selectors. When added, block start working.
Related
I thought I’d be able to update the featured image using this code…
wp.data.dispatch( 'core/editor' ).editPost( { featured_media: 10 } );
However, I get an error:
Uncaught (in promise) Error: The entity being edited (postType, undefined) does not have a loaded config.
What needs to be changed?
Have you tried this:
wp.data.select( 'core/editor' ).getEditedPostAttribute( 'featured_media' );
wp.data.dispatch( 'core/editor' ).editPost({ featured_media: 10 });
I had the same error show up in my browser console, when I was trying to make a custom post type editable through a custom-made block. In my case, it wasn't a problem with the gutenberg block itself (i.e. the js file or the registration of the block), since I could use the block in other post types without the error showing up in the console.
I would suggest checking the slugs/names of any taxonomies (and perhaps post meta fields) which are registered for your specific post type. I think I must have confused the Wordpress REST API as it was loading the post in the gutenberg editor because I had registered a reserved word as one of my taxonomies (I had a taxonomy with machine name "type"). I changed the taxonomy to "taxon_type" (hoping to avoid any name clashes), and the error went away!
I initially thought that it was a problem with a Wordpress API call that I was making in the block itself, but I believe the error message is signaling that the gutenberg editor is having trouble loading your post type for whatever reason.
Can we skip a diazo error and prevent page crash by replacing it with a nice message in page? Something like: Your content you want to show in this page is not created or published. Please check this section /source/homepage-content-sample-section.html.
<!-- Images slider section -->
<replace css:theme="[data-diazo='my-images-slider']"
href="homepage-content/homepage-images-slider" method="document"
css:content-children="#content-core" />
<drop css:content="#content-core [data-diazo='my-images-slider']" />
I have a page in Plone for each section in Homepage, that contains html code easy to edit. The problem is if a page is missing or private the homepage is broken.
Calling user-managed contents with href in a Diazo rule is like playing Russian roulette. If the page is not existing, there is not way to prevent the page crash.
The best approach is to call a developer-defined URL in charge of retrieving the content if it exists and that will just gently return nothing if the content does not exists.
Rapido is a very easy way to do that (you create a Rapido block which can be called like that: href="##rapido/myapp/blocks/get-content-for-my-homepage", this URL will always work, your page will never crash whatever the users have done with the content).
So I have installed a module that gives me a (marque) block.
I can use this block and add it to my website and it works.
But what I want to do is to change the content of the block with a title of a content type.
So instead of:
Marque block: plain text
I want
Marque block: Title emergency messages, if expire date is < now
How can I do this?
Can I get that installed block inside the View of the emergency messages?
Thanks in advance!
You can modify the title of a block by using the hook_block_view_alter(&$data, $block); hook in your custom module.
See the documentation here.
I'm developing a content slider for Wordpress and I would know how is possible to put this content slider (as html content) into the body before the loop.
I tried to filter the content with add_filter('the_content', 'functionName), but I get the content slider before each post.
If you use add_filter('the_content'), your function will be called everytime the content of a post is output, whether a single post or a series of posts in a loop. If you need to "hook" before any post content is output in a page, the only dynamic parts of all WP themes you can reach are get_header() or get_sidebar() (or event get_footer). So your best luck would be not to use a filter with the content, but an action, with get_header, like this :
add_action('get_header', 'your_function'); // Add priority & param args if necessary
The problem is that this gets executed before header.php is called, and usually, the body tag is opened in header.php...
That is if you cannot modify the theme itself. Otherwise, you can easily add an action in the theme itself and execute it where you want.
Another technique would be to add your html content after document is ready, through JavaScript which you can output in the footer.
i have add my region to a info file:
regions[mine] = Mine
then i have created a view with a block display and I add this block to my custom region.
Last, I invoke in my node.tpl.php with:
print render(block_get_blocks_by_region('mine'));
but I have a blank page with html:
Please any help??!!
Why are you invoking that in your node.tpl.php file? This doesn't make any sense in the context. It appears that you want to have a block inside of a region - this is configured in the administration pages, not theme files.
If you are getting a totally blank html page rendered then you likely have an error in your PHP somewhere - Drupal has a habit of swallowing PHP errors without any visible warnings.