Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The newsletter nodes display some strange output in the rendering.
"NoneManage subscriptions" with link to the admin profile edit.
See also image attached:
Proposed resolution
Figure out what element this is and drop it...
And create an issue if functionality of its real purpose is missing.
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#40 | newsletter_node-2410043-40.patch | 1.67 KB | Berdir |
#38 | newsletter_node-2410043-38.patch | 1.09 KB | Berdir |
#31 | interdiff-newsletter_node-2410043-28-31.txt | 1.92 KB | edurenye |
#31 | newsletter_node-2410043-31.patch | 1.64 KB | edurenye |
#31 | newsletter_node-2410043-31-test_only.patch | 734 bytes | edurenye |
Comments
Comment #1
BerdirThat is the newsletter user view element that we always had, with two problems:
- The #theme functions that it is using no longer exists
- it is not defined as an extra field, so it can not be hidden.
The node shows it because they show the user with a special view mode.
This is also in todo.txt already.
Comment #2
miro_dietikerThx for update.
The todo.txt should die (ASAP) and all items will have issues. :-)
Comment #3
BerdirThis is the todo.txt row for this "simplenews_user_view: Uses old #theme functions"
Comment #4
ArlaSo they should be '#type' => 'item' instead, and should be added with simplenews_entity_extra_field_info()?
Comment #5
BerdirA combination of things I guess, an item list for the list of subscriptions, a #type link for the link, maybe a fieldset around it, or something else. And that controlled by an extra field, yes.
Comment #6
mbovan CreditAttribution: mbovan commentedChanged types to 'item' value and added a condition that allows fields to be hidden. Probably it needs some refactoring.
Comment #7
BerdirGood start.
This also no longer exists. I'd suggest a fieldset, as commented above.
It would be slightly different, but I would recommend to use #type link here, and make the whole text the link text.
Comment #8
ArlaWe tried a fieldset but I think those can only be used in forms? We got an error saying something about #attributes. 'details' might be a better choice, but it looks kinda chunky.
Comment #9
mbovan CreditAttribution: mbovan commentedI changed the type from the 'user_profile_category' to 'details' because 'fieldset' gives an error, as Arlid said. Changed the #type for 'Manage subscriptions' to 'link' and made the whole text linkable.
Comment #12
ArlaI guess we want some kind of test here, checking that the output is correct. May be necessary to use xpath to identify the correct elements.
Instead of pushing the whole chunk into an if-body, we can set
$build['simplenews']['#access']
to the value of(bool) $display->getComponent('simplenews')
. That will at least make the diff a lot nicer :)By the way, neither me nor @mbovan could reproduce this on the node view, only on the user view. Something changed there since original issue summary?
Comment #13
BerdirIt might make the patch bigger, but an if (getComponent()) is the common and better pattern. with #access, you will waste processing power loading those subscriptions and then not display them.
Access is often easier/better, but not here.
Can you post screenshots of how it looks, with/without details?
Comment #14
Berdir(or show me)
Comment #15
mbovan CreditAttribution: mbovan commentedHere are the screenshots with and without details type.
Comment #16
mbovan CreditAttribution: mbovan commentedSubscriptions are now rendered as a list.
Here are two screenshots how changes look like with subscriptions and without subscriptions.
Comment #19
miro_dietikerLooks nice. :-)
Discussions about "None" output ended up in possibly being user specific anyway... And hey, they can disable it now, so if they don't like it, they can make it disappear as a whole or submit an issue to improve it. ;-)
Comment #20
BerdirCommitted and fixed.
Comment #22
miro_dietikerAwww... ugly story!
Now for a strange reason, this is polluting nodes:
If i create now an article node, it contains that ugly subscription status widget.
It seems each article kindof triggers a user
In worst case we need to revert this. Otherwise, we need a fix.
Uncool. >:-)
(Node teasers, node detail view, everywhere!)
Comment #23
BerdirThat's not a critical problem ;) And it might be something that we can't fix in simplenews.
What you're seeing is the user, viewed with the compact user mode. You can reconfigure it and it will go away. (workaround => not critical, if we apply the same rules as core ;)).
The problem is that it apparently gets added there by default, because extra fields are made visible there by default it seems. Don't know why. We can only set a default visiblity, so the best we can do I guess is to hide it always by default.
Comment #24
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedNow it's shown in the user and not in the node.
User:
Node:
Comment #25
mbovan CreditAttribution: mbovan at MD Systems GmbH commentedentity_get_display()
is deprecated and will be removed before Drupal 9. We can use\Drupal::entityManager()->getStorage('entity_view_display')
.Btw, should we care about the case when there is no user view display? With this patch if user view display is not present we will get the same thing as without the patch.
Not needed.
Comment #26
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedI made those changes.
Comment #27
BerdirThis wasn't trivial to figure out, lets add a comment about why we do this. That we hide this by default but want to show it for the default view mode.
Also, can we write a test? should be possible to assert that this is not shown on a node in one of the existing tests? We might need to enable the show author setting of the node type for it to work, though.
Comment #28
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedTest done and comments added.
Comment #29
juanse254 CreditAttribution: juanse254 at MD Systems GmbH commentedlooks good to me
Comment #30
BerdirWe already have plenty of UI tests, it is a bit weird to add a UI test class now.
Also, tests always have a Test suffix.
Instead, I think that this would fit well in SimplenewsAdministrationTest::testContentTypes(), where we already create a node and visit it.
Comment #31
edurenye CreditAttribution: edurenye at MD Systems GmbH commentedNeeds to be debugged by Berdir.
I moved the test there and now fails like there where nothing changed.
Comment #38
BerdirSee #2551959: Hardcoded usage of compact view mode in template_preprocess_node() and template_preprocess_comment() is problematic.
Considering that, let's just disable it by default and users have to enable it when they want to use it.
Comment #40
BerdirFixing the tests.
Comment #41
BerdirCommitted.