Last active
May 14, 2019 14:40
-
-
Save jacine/5650cff1e9634c6da27d9cc85cf2616e to your computer and use it in GitHub Desktop.
Node Edit Form - Sidebar (via custom Seven sub theme)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Component template for details element. | |
* https://www.drupal.org/project/components | |
* | |
* Variables: | |
* - summary: HTML/text to display in <summary> element | |
* - details: Main content of details. | |
* - open: If the details element should be open by default. | |
*/ | |
#} | |
{% set open = open ? ' open' : '' %} | |
<details class="js-form-wrapper form-wrapper"{{ open }}> | |
{% if summary %} | |
{% block summary %} | |
<summary>{{ summary }}</summary> | |
{% endblock %} | |
{% endif %} | |
<div class="details-wrapper"> | |
{% block details %} | |
{{ details }} | |
{% endblock %} | |
</div> | |
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Component template for Entity forms. | |
* https://www.drupal.org/project/components | |
* | |
* @see seven_sub_form_alter() | |
*/ | |
#} | |
{{ attach_library('seven/node-form') }} | |
{% block wrapper %} | |
<div class="layout-node-form clearfix"> | |
<div class="layout-region layout-region-node-main"> | |
{% block main %} | |
{{ form|without('actions') }} | |
{% endblock %} | |
</div> | |
<div class="layout-region layout-region-node-secondary"> | |
{% block sidebar %} | |
<div class="entity-meta form-wrapper"> | |
{% block entity_meta_header %} | |
<div class="entity-meta__header"> | |
{% block entity_meta_header_content %}{% endblock %} | |
</div> | |
{% endblock %} | |
{% block entity_meta_content %}{% endblock %} | |
</div> | |
{% endblock %} | |
</div> | |
<div class="layout-region layout-region-node-footer"> | |
{% block footer %} | |
{{ form.actions }} | |
{% endblock %} | |
</div> | |
{{ children }} | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Theme override for a media edit form. | |
*/ | |
#} | |
{% embed '@seven-components/entity-form.twig' %} | |
{% block main %} | |
{{ form|without( | |
'actions', | |
'author', | |
'field_tags', | |
'revision_information', | |
'xmlsitemap', | |
'field_distribution_partner' | |
) | |
}} | |
{% endblock %} | |
{% block entity_meta_header_content %} | |
{{ form.revision_information['revision'] }} | |
{{ form.revision_information['revision_log'] }} | |
{% endblock %} | |
{% block entity_meta_content %} | |
{% if form.field_tags|render %} | |
{% embed '@seven-components/details.twig' with { summary: 'Metadata'|t, open: true } %} | |
{% block details %} | |
{{ form.field_tags }} | |
{{ form.field_distribution_partner }} | |
{% endblock %} | |
{% endembed %} | |
{% endif %} | |
{{ form.author }} | |
{{ form.xmlsitemap }} | |
{% endblock %} | |
{% endembed %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Theme override for a node edit form. | |
*/ | |
#} | |
{% embed '@seven-components/entity-form.twig' %} | |
{% block main %} | |
{{ form|without( | |
'actions', | |
'advanced', | |
'author', | |
'field_editorial_type', | |
'field_kicker', | |
'field_publish_date_display', | |
'group_article_information', | |
'menu', | |
'meta', | |
'path_settings', | |
'publish_date', | |
'revision', | |
'xmlsitemap' | |
) | |
}} | |
{% endblock %} | |
{# This is the sidebar stuff, from here down. #} | |
{% block entity_meta_header_content %} | |
{{ form.meta['published'] }} | |
{{ form.meta['author'] }} | |
{{ form.meta['moderation_state'] }} | |
{{ form.meta['changed'] }} | |
{{ form.meta['revision_information'] }} | |
{{ form.meta|without( | |
'author', | |
'changed', | |
'moderation_state', | |
'published', | |
'revision_information' | |
) }} | |
{% endblock %} | |
{% block entity_meta_content %} | |
{{ form.group_article_information }} | |
{% if form.field_editorial_type|render or form.field_kicker|render %} | |
{% embed '@seven-components/details.twig' with { summary: 'Integrations'|t } %} | |
{% block details %} | |
{{ form.field_editorial_type }} | |
{{ form.field_kicker }} | |
{% endblock %} | |
{% endembed %} | |
{% endif %} | |
{{ form.author }} | |
{{ form.path_settings }} | |
{{ form.menu }} | |
{{ form.xmlsitemap }} | |
{% endblock %} | |
{% endembed %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Needs Component module | |
# https://www.drupal.org/project/components | |
component-libraries: | |
seven-components: | |
paths: | |
- components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
{# | |
/** | |
* @file | |
* seven_sub.theme | |
*/ | |
#} | |
use Drupal\Core\Render\Element; | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function seven_sub_form_alter(&$form, FormStateInterface $form_state, $form_id) { | |
// Remove the "advanced" group in the above base forms, which cover all | |
// variants of node, taxonomy and media entity forms. | |
$base_ids = ['media_form', 'media_edit_form', 'taxonomy_term_form', 'taxonomy_edit_form', 'node_form', 'node_edit_form']; | |
if (!empty($form_state->getBuildInfo()['base_form_id'])) { | |
if (in_array($form_state->getBuildInfo()['base_form_id'], $base_ids)) { | |
foreach (Element::children($form) as $key) { | |
if (!empty($form[$key]['#group']) && $form[$key]['#group'] == 'advanced') { | |
unset($form[$key]['#group']); | |
} | |
} | |
} | |
} | |
} | |
/** | |
* Implements hook_theme(). | |
*/ | |
function seven_sub_theme($existing, $type, $theme, $path) { | |
return array( | |
'media_form' => array( | |
'template' => 'form/media-form', | |
'render element' => 'form', | |
), | |
'taxonomy_term_form' => array( | |
'template' => 'form/taxonomy-term-form', | |
'render element' => 'form', | |
), | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
/** | |
* @file | |
* Theme override for a taxonomy edit form. | |
*/ | |
#} | |
{% embed '@seven-components/entity-form.twig' %} | |
{% block main %} | |
{{ form|without( | |
'actions', | |
'author', | |
'field_tags', | |
'path', | |
'relations', | |
'xmlsitemap' | |
) | |
}} | |
{% endblock %} | |
{% block entity_meta_header %}{% endblock %} | |
{% block entity_meta_content %} | |
{% if form.field_tags|render %} | |
{% embed '@seven-components/details.twig' with { summary: 'Metadata'|t, open: true } %} | |
{% block details %} | |
{{ form.field_tags }} | |
{% endblock %} | |
{% endembed %} | |
{% endif %} | |
{{ form.author }} | |
{% if form.path|render %} | |
{% embed '@seven-components/details.twig' with { summary: 'URL Path Settings'|t } %} | |
{% block details %} | |
{{ form.path }} | |
{% endblock %} | |
{% endembed %} | |
{% endif %} | |
{{ form.relations }} | |
{{ form.xmlsitemap }} | |
{% endblock %} | |
{% endembed %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment