Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to declare blocks in a template as wide or full by default #5948

Closed
AndreaBarghigiani opened this issue Apr 3, 2018 · 1 comment
Closed
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@AndreaBarghigiani
Copy link

Issue Overview

I've been playing a bit on how our themes can create Gutenberg templates but I've noticed that I am not able to set a specific alignment (wide or full) for nested or simple block.

In the handbook is present an array( 'align', 'left' ) but if I set it to wide in a column block Gutenberg stops working and I get the TunyMCE editor (btw congrats for the fallback).

I've been reading the issues of this repo and the handbook but I didn't find any documentation about it.

Steps to Reproduce (for bugs)

  1. Create a CPT
  2. Set a template for the CPT

Expected Behavior

I would like to be able to declare on a per post basis if the current block for the template needs to

Current Behavior

The user can change the alignment of a column block as he likes.

Possible Solution

Insert a new item inside the template array named align or more meaningful names in order to declare something like this:

$args = array(
  'public' => true,
  'label'  => 'Books',
  'template' => array(
      array('core/columns', 
          array(), // Why is it empty? 
          // Proposal array( 'align', 'wide' ), as for standard template
          array(
            array('core/image', array('layout' => 'column-1')),
            array('core/heading', array(
                'placeholder' => 'Add Author...',
                'layout' => 'column-2'
            )),
            array('core/paragraph', array(
                'placeholder' => 'Add a inner paragraph',
                'layout' => 'column-2'
          )),
      ))
  ),
);

Related Issues and/or PRs

#4383 #4747

@mtias
Copy link
Member

mtias commented Apr 3, 2018

This already works, but your syntax is incorrect. You need to define the second argument attributes for align as any other attribute:

array( 'core/columns', array( 'align' => 'wide' ), $children );

@mtias mtias closed this as completed Apr 3, 2018
@designsimply designsimply added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants