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

Add new Fields to the Fields block: post_date, post_modified and author_name #45

Open
2 tasks
bobbingwide opened this issue Jul 12, 2021 · 1 comment
Open
2 tasks
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

In order to support the metadates.html template in FSE themes such as Written I want to replace existing shortcodes with blocks.
I found that the quickest way to implement the solution was to extend the Fields block with a co-requisite improvement to the oik-fields plugin upon which the block is dependent.

See bobbingwide/sb-field-block#5

Requirement

  • Display the post_date, post_modified_date and author_name using a block or blocks.
  • No need for Label as this will be provided in the template/template part.

Solution

  • Extend the oik-block/fields block to add 3 new options to the fieldsOptions
  • Extend oik-fields to support the rendering of the virtual field author_name.
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jun 5, 2022

In the Site editor (beta) the post_id attribute is not passed to the server
so the post date, post modified date and post author field values can't be populated.

For the Author block the prefix is displayed, but for post date and post modified we get block rendered as empty.
image

This is styled with min-height: 200px , so looks wrong.

In the block editor the post_id query parameter is passed. eg. Block editor for post 1269

context=edit&attributes%5Bfields%5D=post_date&attributes%5Blabels%5D=&post_id=1269&_locale=user

What should we do about this?
Simplest thing is to detect a null string being returned in oik_blocks_fields_results() and replace it with the selected field name.

	if( $html === null ) {
	    $html = $fields;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant