backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

[DX] What happened to theme_node_preview() and what can people do now in its place.

Open klonos opened this issue 2 years ago • 4 comments

I know that this sounds like a task for adding documentation and a change record, so better filed under https://github.com/backdrop-ops/docs.backdropcms.org/issues, however, there may be core-related things that we need to do, such as adding a wrapper function with a @deprecated and a watchdog message thrown etc.

This came up in a thread in Zulip:

Hi, in D7 we used theme_node_preview to modify how a node is previewed before saving, and I'm trying to get the same result in Backdrop, but it seems that in Backdrop there's a different approach to doing this. But I can't understand what it is! It looks like I should use node_preview. Can someone explain how this would be done?

Here's what we know:

  • We've removed node previews completely in Backdrop v1.0.0 with #218 and https://github.com/backdrop/backdrop/pull/601
  • We then re-introduced node previews much more improved in v1.11.0, with #3062 and https://github.com/backdrop/backdrop/pull/2290
  • We iterated after that, with a series of follow-up bug fixes and UX improvements:
    • #3275
    • #3336
    • #3338
    • #3361
    • #4856
    • #5018
    • #5067

Clues: In the original PR that reintroduced the node previews, there's a @see node_form_build_preview() in the docblock of node_preview(), however that eventually has changed to @see node_form_preview() later. I cannot see any theme function being called in that function, so not sure how people can override it 🤷🏼

klonos avatar May 30 '23 19:05 klonos

PR available now. To test, override THEME_NAME_node_preview() in template.php. The render array will be available in $variables['node_preview']

docwilmot avatar Feb 09 '24 15:02 docwilmot

Simple enough. I've tested and reviewed. RTBC

herbdool avatar Feb 14 '24 14:02 herbdool

I agree with @herbdool, this is simple and looks good 👍🏼

Setting the milestone, and back to NW since there are some nits in the PR thread.

klonos avatar Feb 17 '24 19:02 klonos

I've resolved all the PR comments, ready for review again.

docwilmot avatar Mar 09 '24 22:03 docwilmot

Thanks @docwilmot, @klonos, @herbdool, and @kiamlaluno! I merged https://github.com/backdrop/backdrop/pull/4652 into 1.x for 1.28.0. It could have been backported to 1.27.2, but I added the @since 1.28.0 and that release is right around the corner, so I hope that should be acceptable.

quicksketch avatar Apr 28 '24 20:04 quicksketch

Tiny follow-up PR to add further @since lines with additional details/links to the functions that have previously been removed and since re-added: https://github.com/backdrop/backdrop/pull/4725

klonos avatar May 01 '24 23:05 klonos