In Drupal 7, when the Body field is defined as "Long text with a summary", the summary field is displayed if the user clicks on the link labeled "Edit summary."
There's no apparent way to either display the summary field by default or make it required.
The problem is that if the Summary field isn't displayed, it will get ignored. On virtually every site that my company builds, we use required custom teaser fields so we can create a teaser that is not limited by the severe constraint of producing a teaser from the first part of the body field. The "Long text with summary" field type partially addresses this same need, but it's too easy to ignore, which leads to page summaries made by clipping the body copy, which we regard as really problematic.
So, I'd like to be able to do either or both of two things:
- Make the summary required (which would presumably kick the user back and display the summary field if they didn't click to edit it the first time);
- display the summary field by default. (This is my preferred solution.)
Any suggestions?
Comments
Workaround
Workaround: Add
as default text to the Summary field, which will:Not a very satisfactory solution, as it prevents failover to a truncation-summary. Better solution would be to have the summary field visible at all times, and not visible only when requested.
This is BY FAR the best
This is BY FAR the best workaround! Just edit the field settings, click on the summary button and add a blank space as the default value! Works like a charm :)
Not ideal
I've been using this. The downside is that hardly anyone thinks to delete the non-breaking space when adding content. And staff still overlook the field.
Actually, even if I put a prompt to add some text, many staff don't enter anything, and the prompt shows up on the website.
The only real solution that is guaranteed to get content into that field is to leave it empty, always show it, and make it required.
Charles Belov
SFMTA Webmaster
http://www.sfmta.com/
Anyone come up with a viable
Anyone come up with a viable fix for this? Defaulting summary text to a space is not really an option for me.
text.js
The showing and hiding of the summary is done by the code in /modules/field/modules/text/text.js
One could hack core (shudder) or write some js to reverse the initial hiding of the summary.
Try hook_js_alter() to
Try hook_js_alter() to override the path for modules/field/modules/text/text.js.
In your local version of text.js you can just comment out the $link.click(); on line 41 - this will stop the initial collapse of an empty field.
See more at http://drupal.org/node/756722
Thanks a lot!
Thanks a lot!
Is this naughty?
Is this Naughty? Or is this okay to do? So will this force just the summary empty field from collapsing or all of them?
If so is there a means to select solely the summary field on. Or just have it forced on by default. Seems like a common problem.
Slightly naughty but efficient..
.. did it for me :)
Worked perfect for me, thank
Worked perfect for me, thank you!
Possible solution with custom module
If you want display the summary and just get rid of the show/hide functionality and make it a required field, create a custom module with the following code (replace mymodule with your module name):
The above assumes you don't have any languages set up, otherwise the hook_node_validate code will be slightly different.
~Chad
Amazing
Adding a space may be a cheap trick, but it gets the job done. It's solved quite a few issues with my site by doing this. Thank you thank you thank you!
I am looking for the reverse of what has been discussed here.
Yes we use the summary field and it is important for the mechanics of our sites and is usually populated by site owners/editors. However, I want the summary to be closed by default as it confuses site contributors and often results in them deleting or changing the summary when we don't want them to
There is not a one size fits all solution here. But there is a good case for a custom module and I wonder whether one exists already??? It should behave as below.
Set defaults for node summary
It should probably exist as a conditional field which is revealed when 'Summary input' is selected on a content type.
If anyone can point me to a module that does this. I'd very very happy indeed :-)
---
Paul Driver
www.easable.uk
Ilkley, West Yorkshire, UK
Summary settings module
I've just created a new module for this. Please see https://drupal.org/project/summary_settings
Perform a form_alter to keep showed
Hi,
If you wanna to let the summaries openned by default in field_collection, you could use this :
Regards, Benftwc ;)
Thanks for the module
All other ideas where nice but have their drawbacks
Summary Field
One would think that such a simple but obvious requirement would be standard core. I ran into this problem when D7 was first launched and solved the problem by creating and additional body called summary which was time intensive but gave control over character limitation display and required.
Thank you Mstrelan for this great module will make my job and many others much more simpler.
Works like a charm :)
Separate field
The downside of a separate field is that it will not show up in the teaser.
Charles Belov
SFMTA Webmaster
http://www.sfmta.com/
If you want to show up the
If you want to show up the separate field in teaser, you have to use DS module.
May be a little late, but I
May be a little late, but I leave it as reference for future.
It Works
Thanks for posting this.
To make the summary field
To make the summary field both required AND visible by default, use the following code in your custom module:
Change the summary field's class to disable the JS
text.js works off the summary field having class "text-summary".
If you change the class to something else then the code in text.js won't execute, and it won't show the "Edit summary" or "Hide summary" links either. The result is that the summary and body fields will show as two separate normal fields.
To achieve this effect add this code to a custom module:
Another alternative
In true Drupal style, here is another way to solve it. I took the best of the solutions from above (thanks), but in my case I wanted to be able to have this setting as an option on all summary fields. This can be improved on to disable the choice if the summary field is disabled ... but here you go ...
If you use this, you will need to go to your Manage Fields page and check the 'Summary is required' field. When checked, the field is made visible by default and required (the description text is tweaked a little too).
This works great, there's one
This works great, there's one error in the code though: it's using a variable $instance that's not be initialised, here's the correct version:
Also for my use case I decided to split the options to always show and make required into two options and added a max word count option.
I created a simple module called text_summary and here's the full text_summary.module for anyone that wants to use it:
Summary Options Module
I noticed this thread was a bit older but still active. There is a module for most of what has been suggested in this thread:
https://www.drupal.org/project/text_summary_options
---
Shane Birley
Left Right Minds
https://www.leftrightminds.com
Summary Options is my preferred option
I agree. This module will display the Summary field by default, and also allows you to make the Summary field required. Available for both D7 and D8.
I provide Drupal, Drupal Commerce and CiviCRM development services for customers in New Zealand and beyond
Yet another way
In a hook_form_FORM_ID_alter() or hook_form_alter()
To remove the js attachment.
That worked!
That worked great - thank you!
Drupal 8: #attributes instead of #attached
I discovered unsetting the #attributes property achieves the same result by removing the classes from the wrapper div:
This technique is also compatible with Inline Entity Form, where unsetting #attached failed to disable the jQuery collapsible behavior:
node:summary not displaying
I used [node:field_summary] and it worked perfectly. Could there be any downside to using that?