Skip to content

Issue #6893: Add a block render function outside layouts #5076

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

Open
wants to merge 10 commits into
base: 1.x
Choose a base branch
from

Conversation

avpaderno
Copy link
Member

@backdrop-ci
Copy link
Collaborator

Related to: backdrop/backdrop-issues#6893

Benjamin Wheeler added 3 commits May 16, 2025 14:09
Move block render code outside layouts

This commit moves the block render code outside layouts so that third
party modules can render blocks without having to re-implement core
code.
I totally borked this block_render function.
After looking through this, it appears that layout module doesn't
require the block module so it was throwing an error about not finding
block functions. I figured we probablty didn't want to make layout
depend on block so I've moved those functions into the layout module.

Fixes backdrop/backdrop-issues#6893
@bennybobw bennybobw force-pushed the 6893-block-render branch from 50a448f to 696e43f Compare May 16, 2025 18:40
Benjamin Wheeler added 4 commits May 17, 2025 13:29
I had to change a few things to get the test to run -- namely after the
block hooks run it returns a string instead of an array. In order to get
the layout contextual links to be added I had to switch it back to an
array. I'm not super happy about how that code is, but I'm going to
tackle that in another commit.

Fixes backdrop/backdrop-issues#6893
I've moved layout_block_get_renderable_array to the Block class which I
think I kind of like. I renamed it getRenderArray() for brevity and I
think they're called render arrays in the documentation. I didn't like
that the function assumed that $block_prepare() was called, so I've
added a new property to the block class $isPrepared that we can check in
getRenderArray().

Fixes backdrop/backdrop-issues#6893
Copy link
Contributor

@herbdool herbdool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bennybobw generally it looks good! I added a few suggested changes for consistency. I haven't tested this at all.

bennybobw and others added 3 commits June 6, 2025 11:49
Changed getRenderArray() to build(). Made some documentation changes.
@dragonbot
Copy link
Collaborator

Tugboat has finished building a preview for this pull request!

Website: https://pr5076-dpodjcpubcljnovljnmlbz4gftblsuue.tugboatqa.com/
Username: admin
Password: a5a7c5536b94

This preview will automatically expire on the 6th of August, 2025.

@bennybobw
Copy link

@herbdool

This is my first time using this "requested changes" feature so I apologize if I've messed it up. I clicked the button to include some of your changes and then also made a commit.

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

Successfully merging this pull request may close these issues.

Add a block render function outside layouts
5 participants