block-visibility icon indicating copy to clipboard operation
block-visibility copied to clipboard

Show/Hide when Printing

Open MadtownLems opened this issue 2 years ago • 4 comments

What problem does this address?

We have Blocks that make sense when viewing online, but shouldn't be printed out if the user prints the page. It would be great if Block Visibility pro could hide certain blocks from printing. (I'm sure there are also cases where people want blocks to show ONLY when printed as well; that's just not our current need.)

What is your proposed solution?

Add a basic control that allows blocks to have their visibility based on whether or not we're currently printing.

MadtownLems avatar Dec 02 '22 15:12 MadtownLems

And in 5 minutes, we realized why we would definitely want to be able to show some blocks ONLY on printing, as well. :)

Example: We embed a youtube video. When someone prints, it just doesn't show up. We'd like to have a print-only block below it that shows a still image of the video along with the URL.

MadtownLems avatar Dec 02 '22 15:12 MadtownLems

Hmm, this is an interesting use case. Have you considered using a Block Style for this? Or even a dedicated utility class?

I believe controlling print visibility would need to be done with CSS. Currently, only the Screen Size control uses CSS. All other controls actually removed the block from the page via the render_block hook. I'm a bit hesitant to add more CSS-based controls since they can so easily be overwritten unintentionally by theme or user styles. 🤔

ndiego avatar Dec 02 '22 19:12 ndiego

Have you considered using a Block Style for this?

My main issue with Block Styles is the "select only one" nature of them. Take a Heading Block, for example. We have several different styles. What if I want "Red Lines on Both Sides" styles AND to hide it from printing?

I suppose it could be a Group style, and then you'd put the Heading (red lines style) inside the Group Block (hide when printing style), However, it sure feels pretty clunky using "Styles" to apply conditional logic.

Group Block Style - Hide when Printing Group Block Style - Show only when Printing

Or even a dedicated utility class?

Another fine option for many, I'm sure. However, we're really trying to avoid this as much as possible, mostly because it's not really a great user experience for our content providers. Having to know that it's even an option, and remember the specific class, isn't ideal.

Totally get the reluctance to implement more CSS-based controls, of course. I thought it might be a good fit for Block Visibility, but completely respect the decision to not implement at this time. Cheers!

MadtownLems avatar Feb 24 '23 16:02 MadtownLems

Got directed here from the forums and will add my vote for this.

I think it would go well with the screen size options which is also controlled by CSS, it could even be in the same place (as a checkbox below "hide on mobile"). While it could interfere or be overridden with other CSS styling it is unlikely, especially in the case of print. I belive there are a few dedicated printing plugins, but most themes don't bother with printing at all. If someone have a printing plugin they could just choose to disregard the option in this plugin.

The main use would be to hide navigation, CTAs and similar content (stuff that went into widgets in classic themes) that doesn't make sense when printed. For example if you have a mega menu all of it may be printed taking up several pages of print before the actual content.

Block styles wouldn't work as they don't stack, but of course adding a dont-print class to blocks is possible (and trivial for anyone with knowledge of CSS). It just would be nice if this plugin took care of that as well.

audunmb avatar Jan 30 '24 20:01 audunmb