Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I have a view using the table format. In the table settings I have "Show the empty text in the table" checked. I also added a Global:text area in the Header of the view. It contains a "hard-coded" link to add a particular type of entity. In the header settings, I have the "Display even if view has no result" checked.
Despite these two settings, if there is no content in the table, the view does not get rendered nor does my link from the views header. Is there are way to show the empty view so the "add [content]" link shows or is there another way to add the link?
Thanks,
Mickey
Comments
Comment #1
mkadin CreditAttribution: mkadin commentedMickey, EVA should still display the view. I've just tested it on a local dev environment for me and it showed up just fine. Have you successfully gotten the view to show up when there are results? Perhaps that's the issue, and not the no results behavior.
Comment #2
micnap CreditAttribution: micnap commentedHi,
Yes, the view shows fine where there is content to display. It is used on a custom entity type created by a third party module (Redhen) though, and not a standard node, if that makes any difference. I've just discovered hook_menu_local_tasks_alter, however. I'm thinking that may be the better way to go in this instance rather than hard-coding the link.
Thank you for the quick response!
Mickey
Comment #3
mkadin CreditAttribution: mkadin commentedWell that does sound like a bug then...It could be related to the custom entity, but if it is successfully attaching when there is content then it'd be weird to only show up when there's no view results.
If you want to help me track it down, maybe you could spend a few minutes dsm()'ing inside eva_entity_view_alter() in eva.module. I'd be interested to see the results of calls to _eva_extract_entity_from_build($build), eva_get_views($type), and $view->execute_display($info['display']).
Comment #4
micnap CreditAttribution: micnap commentedWell, the local_tasks_alter didn't work out so well, so I'm back to this.
I traced it all the way down to the eva_plugin_display_entity class. In the execute() function, the three eva views I have on the site ARE being rendered. But $data isn't being returned because none of the conditions in this:
if (!empty($this->view->result) || $this->get_option('empty') || !empty($this->view->style_plugin->definition['even empty'])) {
is true. I'll trace it further tomorrow.
Thanks,
Mickey
Comment #5
micnap CreditAttribution: micnap commentedThe trick to getting the view to show is to use the No Results Behavior settings under the Advanced section in the view, NOT the No Results Behavior setting under an individual field in a view.
Fixed.
Dupal - 9,345 : Mickey - 0
[banging head on desk]
Comment #6
windmaomao CreditAttribution: windmaomao commentedi found a even better way, add a custom text field to he No Results Behavior, and then add a space there just to trigger view display.
then you can use header or footer as used to be.
Comment #7
annie2512 CreditAttribution: annie2512 commented#5 resolved my issue. Now when view has no results, it display the content in No Results Behavior settings under the Advanced section. Thanks @micnap