- Issue created by @jsheffers
- πΊπΈUnited States jsheffers
Might be compatibility issue with the Gin theme:
I don't see these options available with the Mercury editor. Has anyone done this?
Yes, I found this too. When switching the admin theme back to Claro, there's a "Publish" tickbox at the bopttom of the screen. But I can't see how it's possible to publish with Gin
- π¬π·Greece dotoree
The problem is that status field belongs to gin_actions group and form renders without this group, so we need to move status out of this group.
Not sure in which level should be patched, but you can override the template through a custom module to fix the problem:
a) create a new module 'my_module' and make sure that executes after mercury_editor
b) create a template in my_module/templates named 'mercury-editor-entity-form--custom.html.twig' with contents:
{# /** * @file * Theme override for a node edit form. * * Single-column template for the node edit form. * * @see claro_form_node_form_alter() */ #} {{ attach_library('mercury_editor/node_form') }} {{ form['status_messages'] }} <header class="me-node-form__header"> <h1 class="me-node-form__title">{{ form['#title'] }}</h1> </header> {# Remove status group when in gin_actions #} {% if form.status['#group'] == 'gin_actions' %} {% set status = form.status %} {% set status = status|merge({ '#group' : null }) %} {% set form = form|merge({ status: status }) %} {% endif %} {{ form|without('status_messages', 'advanced', 'footer', 'actions', 'gin_actions', 'gin_sidebar', 'gin_sidebar_toggle') }} {{ form.advanced }} {{ form.actions }} {{ form.footer }}
c) in my_module.module:
/** * Implements hook_theme_suggestions_alter(). */ function my_module_theme_suggestions_alter(array &$suggestions, array $variables, $hook) { switch ($hook) { case 'node_edit_form': if (in_array('mercury_editor_entity_form', $suggestions)) { $suggestions[] = 'mercury_editor_entity_form__custom'; } break; } } /** * Implements hook_theme(). */ function my_module_theme($existing, $type, $theme, $path) { return [ 'mercury_editor_entity_form__custom' => [ 'base hook' => 'mercury_editor_entity_form', ], ]; }
- πΊπΈUnited States boinkster
I can confirm that this a Gin problem. Tried the fix in #4 and the twig isn't loading. I haven't had time to track down what changed and where it's failing. If this isn't too much of a moving target, maybe it should be an extra module in Mercury or contrib.
- π¬π·Greece dotoree
@boinkster: One potential caveat is that your custom module (aka 'my_module' in example) should fire after mercury editor. This can be done with some something like Modules Weight β module or with custom code.
- π¬π·Greece dotoree
The problem still exists with gin 3.0.0-rc14 and mercury_editor 2.1.3, dev versions as well. I can't tell if it's Gin or ME problem.
- π¬π·Greece dotoree
Yet again, the problem still exists with gin 3.0.0-rc15 and mercury_editor 2.1.6 .
If it helps anybody, I came up with a hack in a custom module to prevent nodes to be unpublished. I assume that the site has a node bundle 'mercury_enabled_page' that uses mercury.
use Drupal\node\NodeInterface; /** * Implements hook_entity_presave(). * * Temporarily hack for issue https://www.drupal.org/project/mercury_editor/issues/3406870. */ function my_module_entity_presave(\Drupal\Core\Entity\EntityInterface $entity) { // Check if the entity is a node and of the bundle 'mercury_enabled_page'. if ($entity instanceof NodeInterface && $entity->bundle() === 'mercury_enabled_page') { // Get the referrer URL from the global request. $referrer = \Drupal::request()->server->get('HTTP_REFERER'); // Check if the referrer URL contains 'mercury-editor'. if (strpos($referrer, 'mercury-editor') !== FALSE) { // Set the node status to TRUE (published). $entity->set('status', TRUE); } } }
- π¬π·Greece dotoree
Update issue's version to 2.1.6 as it's not only present on ^2.1@alpha.