- 🇺🇸United States beunerd Providence, Rhode Island
@ras-ben @mlncn
First, this function --
workflow_buttons_preprocess_node(&$variables)
-- creates two (not one) optional variables for use in node templates:$current_revision_state
and$latest_revision_state
.Second, why is this "completely redundant"?
Third, as I explained here 🐛 workflow_buttons should only be loaded/load edit form when relevant Fixed in more detail, checking for view display mode by name is arbitrary and may differ between installations.
- 🇩🇰Denmark ras-ben Copenhagen
@beunerd apologies for the slow reply on the other ticket. I dont know why it's flown over my head.
It's quite many months since i created this patch, so i'm trying to remember - but, from reading my comment, it appears that I've missed that there's a second variable being set.
The variable i did notice - latest_revision_state - was not being used for anything, when I searched in the code.
That's why I called it fully redundant.However, when I look in the code, it appears that "current_revision_state" is the same - it's being set, but not being used anywhere. Am i wrong?
Let's continue the discussion on full/viewmode in the other ticket :) https://www.drupal.org/project/workflow_buttons/issues/3328538 🐛 workflow_buttons should only be loaded/load edit form when relevant Fixed
- Status changed to Active
about 2 years ago 1:12pm 2 August 2023 - Status changed to Closed: won't fix
about 2 years ago 3:04pm 2 August 2023 - 🇺🇸United States beunerd Providence, Rhode Island
Thanks, @ras-ben, for the follow up.
but not being used anywhere.
That's correct. This module does not include any twig/template files where the values set in
workflow_buttons_preprocess_node()
would be rendered. The point is to provide those variables to any Drupal theme that wants to use them in their own node-related template. - 🇩🇰Denmark ras-ben Copenhagen
Right, but what would the use case for that be in a template?
It seems overkill to send the data along for no reason, and using a hook in the process - 🇺🇸United States beunerd Providence, Rhode Island
Hmm, so maybe we just move it to the README as an example in case themers want to know?
- Status changed to Needs work
about 2 years ago 4:43pm 2 August 2023 - 🇺🇸United States beunerd Providence, Rhode Island
Actually, I'm realizing this doesn't have any place in workflow_buttons module -- at most it should be added to the core issue queue as a proposal for the workflows core module. It's not related to workflow buttons.
@mlncn What do you think? Is it worth creating a ticket in core for adding the code in this hook? And do you agree we should remove it entirely from this module? And if we do, how do you propose we make sure sites using this module are informed?
- 🇺🇸United States mlncn Minneapolis, MN, USA
We'll remove it from 2.0.x and put the change in the release notes.
It is of course unlikely to get these variables into core quickly so we should create a contrib module, but should also file a core issue in the Workflows queue like beunerd suggested.
To belatedly provide the use case for this variable, in a
node--full.html.twig
:{% if not node.isPublished() %} {% if current_revision_state == 'trash' %} {% set version_state_message_title %} {% trans %} This {{ content_type }} has been deleted. {% endtrans %} {% endset %} {% set version_state_message_subtitle %} {% trans %} You can restore it by editing. {% endtrans %} {% endset %} {% elseif node.isDefaultRevision() %} {% set version_state_message_title %} {% trans %} This {{ content_type }} is not yet viewable by the public. {% endtrans %} {% endset %} {% set version_state_message_subtitle %} {% trans %} Please complete and publish it soon! {% endtrans %} {% endset %} {% else %} {% set version_state_message_subtitle %} {% trans %} This {{ content_type }} {{ current_revision_state }} has not yet been published. {% endtrans %} {% endset %} {% set version_state_message_subtitle %} {% trans %} An older version is published; please complete and publish this latest {{ current_revision_state }} soon! {% endtrans %} {% endset %} {% endif %} <section class="hero is-danger is-bold"> <div class="hero-body"> <div class="container"> <p class="title">{{ version_state_message_title }}</p> <p class="subtitle">{{ version_state_message_subtitle }}</p> </div> </div> </section> {% endif %}