If the "Include View Title" extra setting is disabled in field configuration, then the view title will anyways be displayed via the viewsreference__view_title template. This extra setting ignores whether the plugin is set to enabled in the $enabled_settings variable.

This screenshot shows the edit field settings, if the 'Include View Title' box is not checked, the viewsreference__view_title template should not be rendered above the view:
Screenshot of the edit field settings for the viewsreference field

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

John Pitcairn created an issue. See original summary.

_shy’s picture

Status: Active » Needs review
StatusFileSize
new5.49 KB
new49.97 KB
new22.42 KB

Here is a patch to fix this issue. Added "Display view title" as default option. Also it's removed from the "Enable extra settings" section to avoid any misunderstandings.
edit-form
settings-form

johnpitcairn’s picture

Thanks. This doesn't really address the issue.

There are many situations where I don't want my site editors to make the decision whether to show the view title, and some situations where they should. Removing the extra setting means the checkbox is always visible to my editors, and therefore always editable by them.

In the situations where I do not want them to make that decision (checkbox hidden), I still need to be able to show or hide the view title on a per-field-instance basis.

So in the field settings, there needs to be a way to hide the view title checkbox, AND a way to specify whether the title is displayed when that checkbox is hidden.

This could be an additional checkbox (labelling for the two related checkboxes might be tricky), or (perhaps better) a select element with three possible options detailed:

  • Always show the view title
  • Always hide the view title
  • Let users show or hide the view title

The first two would hide the view title checkbox, and always show or hide the title.
The last one would show the view title checkbox, and allow the default to be set.

johnpitcairn’s picture

Status: Needs review » Needs work
_shy’s picture

StatusFileSize
new32.94 KB
new6.23 KB

Thanks for the pertinent remark!
We should make this things customizable as much as possible for comfortable work. You are absolutely right about these cases.
So, I tried to find a workaround for this. Made some changes according your comments.

Now we can choose different settings for the view title displaying.
First two option is pretty clear.
"Let users show or hide the view title" option provide possibility for the editors to choose show or hide View title.

Probably the main problem is that you should re-save node edit form to apply changes.

form

_shy’s picture

Status: Needs work » Needs review
johnpitcairn’s picture

Thanks, looks great! I'll try to test this soon.

Probably the main problem is that you should re-save node edit form to apply changes.

That's core behavior for the default value setting, so we shouldn't try to address that here.

johnpitcairn’s picture

Thanks, nice work, I think the radio buttons are fine. There's still a consistency problem for site builders though, it isn't reversible:

If the field setting is "Let the user show or hide the view title", and the user shows the title in the content form, it is displayed as expected when viewing the content. But if the field setting is then changed to "Always hide the view title", the title remains displayed when viewing the content.

The reverse is also true. If the field setting is "Let the user show or hide the view title", and the user hides the title in the content form, it is hidden as expected when viewing the content. But if the field setting is then changed to "Always show the view title", the title remains hidden when viewing the content.

I would expect changing the field setting to override any prior settings made by the user. The output shoud first check the field setting, hide or show the title output accordingly, and only defer to the content form setting if the field setting is "Let the user show or hide the view title".

_shy’s picture

Thanks for your efforts!

I would expect changing the field setting to override any prior settings made by the user.

You are absolutely right. I'll check it out and fix it soon!

johnpitcairn’s picture

Status: Needs review » Needs work
_shy’s picture

StatusFileSize
new8.07 KB

Fixed issues mentioned by John Pitcairn in the comment #8.
Seems to work fine now. Please check it out and let me know if you have some suggestions how we can improve this functionality.

_shy’s picture

Status: Needs work » Needs review
johnpitcairn’s picture

Status: Needs review » Reviewed & tested by the community

Thanks again, this is working well. With this patch, site builders can now:

  • Show or hide the view title globally per field instance.
  • Delegate control over the view title visibility to content editors.
  • Override that delegation per field instance if it has been previously set by a content editor.

A quick code review looks good too. RTBC from me, great work!

johnpitcairn’s picture

Hmm ... see also #3253860: Make title display configurable, which adds a field formatter setting that will blindly override these prior settings. Thoughts?

We probably need to consolidate these 2 issues.

chris--s’s picture

Composer fails to merge patch in #11 against current dev. Attached patch fixes that.

oadaeh’s picture

Here's another updated patch for more updates in dev.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: viewsreference-view-title-display-3224064-16.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

shani maurya’s picture

Hi Tried patch #15 but it did not work. In version 2.0 we don't have the option like 1.8 for the "Include View Title" on the specific content level.

nelo_drup’s picture

Same problem as number #18, the option to deactivate the title does not appearSame problem as number 18, the option to deactivate the title does not appear

oadaeh’s picture

I recreated my patch based on #11, so the missing option should be there.

oadaeh’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 20: viewsreference-view-title-display-3224064-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

kurttrowbridge’s picture

Status: Needs work » Needs review
StatusFileSize
new7.79 KB

Here's patch #20 again, this time with the PHP CodeSniffer issues resolved.

Status: Needs review » Needs work

The last submitted patch, 23: viewsreference-view-title-display-3224064-23.patch, failed testing. View results

daisyleroy’s picture

Same problem here on 2.0.beta7, resolved by adding a title display settings verification (check also that your field formatter settings has always the title display option to false ), that worked for me.

daisyleroy’s picture

StatusFileSize
new1.65 KB

Sorry I made a mistake during the previous patch generation. Please ignore it and try this one.

tushar1’s picture

Hi daisyleroy, facing this issue: "$this" can no longer be used in a plain function or method since PHP 7.1 while applying patch #26 on this 2.0.beta7 version..

tushar1’s picture

Updated the patch by fixing this issue: $this" can no longer be used in a plain function or method since PHP 7.1 now able to apply on 2.0.beta7..

hudri’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)
Related issues: +#3402036: Configuration schema for "Enable extra settings" (title,pagination,...) incorrect

There is some much deeper problem here, something is wrong with the functionality and storage of this option in 2.0-beta7

In the field settings, the title value can not be saved at all. I guess there is an incorrect schema:

viewsreference.schema.yml

field.field_settings.viewsreference:
  type: mapping
  label: 'Viewsreference field settings'
  mapping:
    enabled_settings:
      type: sequence
      label: 'Enabled settings'
      sequence:
        type: viewsreference.enabled_settings.[%key]

viewsreference.enabled_settings.title:
  type: boolean
  label: 'Include View Title settings'

However, in the field config we see this structure:

field.field.ENTITY.FIELDNAME.yml

settings:
  enabled_settings:
    argument: argument
    pager: pager
    title: true <--- this does not look correct here, I believe the value should be 'title' here

I also tried manually hacking the config value to 'title' and then importing, but the display title option still was not rendered in the form.

I tested patch #28 and it did not have any noticeable effect on my site, did not change anything.

#25 mentions a field formatter / display setting. This setting was visible one time. But after changing settings in the field storage, the "display title" option in the field formatter / display setting was gone forever (tried removing and re-patching, but the display option in the field formatter was lost). I also don't understand why a field formatter option is necessary at all, when this feature exposes that setting to the editor.

To me it seems all the patches miss the problem. In regard of title display:
- none of the patches here for 2.0-beta7 works
- 2.0-beta6 works
- using 2.0-beta7 without any of the patches here and simply manually deleting the schema file works

I'm closing this issue in favour of issue 3402036.

If you are using 2.0-beta7 and have problems with the views title display, use the patch the issue linked above.

scott_euser made their first commit to this issue’s fork.

scott_euser’s picture

Title: View title is always displayed if the extra setting is hidden » View title is always displayed even if the extra setting is hidden
Issue summary: View changes
Status: Closed (duplicate) » Needs review
StatusFileSize
new11.83 KB

The issue summary was quite a bit out of date as are earlier screenshots of the UI. I updated it to match the current state. Re-opening this as the current state still shows the view title view plugin regardless of whether the plugin is enabled or not. This is because this plugin is loaded differently compared to plugins that affect the view itself: this plugin is loaded above the render of the view with its own unique code to load it.

scott_euser’s picture

Title: View title is always displayed even if the extra setting is hidden » Only render the view title if the 'Include view title' plugin is enabled
trickfun’s picture

Patch doesn't work.

scott_euser’s picture

Patch should work now. Could you please confirm?
Test coverage also added.

scott_euser’s picture

So current situation with this MR is now:

  1. 'Include the view title' plugin not enabled on the field: No title shown
  2. 'Include the view title' plugin is enabled on the field: Checkbox unchecked: No title shown
  3. 'Include the view title' plugin is enabled on the field: Checkbox checked: Title shown
ershov.andrey’s picture

Updated patch for the 8.x-2.0-beta10

rossb89 made their first commit to this issue’s fork.

rossb89’s picture

Updated the merge request to merge in the latest 2.x changes.

Can't use a patch file generated from that with composer as it includes modifications to the tests directory contents which is actually specified in the .gitattributes file to export-ignore:

/tests export-ignore

So to use this currently (on beta10) (before this MR is hopefully merged in at some point), you'll need to use the patch here made by @ershov.andrey.

rossb89’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the changes do what @scott_euser states in comment 36, marking as RTBC.

anybody’s picture

@scott_euser any chance to merge this and tag a new release? This is a really annoying thing not having the control about views title output.

Thanks!

anybody’s picture

StatusFileSize
new4.2 KB

Static patch attached until this is merged.

  • scott_euser committed f496d9b0 on 8.x-2.x
    fix: #3224064 Only render the view title if the 'Include view title'...
scott_euser’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone! It doesn't contain the new feature described in #2 but does contain the bugfix. The separate feature described in #2 I think would need to be a separate views reference plugin as its a different behaviour than 'Include the view title' describes. But to note, would like to keep viewsreference simple without too many plugins, so consider viewsreference_extras or just own plugin if you want that feature still.

Thanks all

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

scott_euser’s picture

In terms of release, I'd like to get #3578487: Compatibility with Drupal 11.3.0 AJAX History: Relationships fail and crash field rendering on page reload in + #3583101: Upgrade to OOP hooks, php attributes, and other deprecation resolving after that. If anyone is willing to help, particularly testing the former. The latter should be quite quick to do and not need any notable back and forth.

scott_euser’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ericdsd’s picture

Note that i had to resave my viewsreference field settings to have the title hiddenwith "Include View Title" unchecked, it's possible that it was just the consequence of a previouly applied patch for this same issue.

Leading to this config change :

--- a/config/sync/field.field.paragraph.view.field_pa_view.yml
+++ b/config/sync/field.field.paragraph.view.field_pa_view.yml
@@ -27,5 +27,4 @@ settings:
   preselect_views: {  }
   enabled_settings:
     argument: argument
-    title: true
 field_type: viewsreference
scott_euser’s picture

Very possible, earlier patches were quite different than what was merged

johnpitcairn’s picture

Sorry for the late comment.

Does this fix provide a way to configure the field to always show the view title, while preventing editors from changing that, as per my comment #3?

scott_euser’s picture

Re #51 no it does not unfortunately per my comment in #44. The problem with this original bug is it resulted in people using the buggy state like #3585918: Provide sample update hook to auto-tick 'Include the view title' for existing views reference field uses so there is no perfect world where some people don't have to have a post update script.

For getting your proposed control in however that'd not have that problem, because with 'Include the view title' ticked, if we eg renamed it to like 'View title display inclusion' as long as enabled + default setting would include the view title, your additional proposed feature could be added.

Given the problematic nature of the original issue (in that some sites expect title shown/others don't expect title shown) I think as maintainers we should be okay to add in such a feature to that plugin (even though I've heard from other maintainers the desire to effectively push any new plugin to eg views reference extras and keep this focused on the core functionality only) so unless other maintainers disagree, I'm personally happy for someone to make a followup to add your suggestions in (as long as it includes test coverage as well).

At this stage I had prioritised fixing the bug itself to avoid further people having diverging expectations of the default state (ie the title + issue summary of this issue). But yeah as I noted in that other issue, given some relied on the bug, others relied on the patch, there was no pleasing everyone there it seems. Tricky one!

johnpitcairn’s picture

Thanks for the clarification. When this particular site next needs any work done I will look at a followup issue if editor feedback and usage patterns require one.