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 cck text field field_review_comments which I want to automatically generate the title for the node. I am using the token [field_review_comments-raw] in order to generate the title, but Automatic Nodetitles module makes the whole content of the field as the title. I only want the first 30 characters from this field to be part of the title. Is there some way to trim it down to the first 30 characters?
Also what is the difference between raw and formatted? I am not sure which token to use, [field_review_comments-raw] or [field_review_comments-formatted]
Comment | File | Size | Author |
---|---|---|---|
#6 | 668308-6.patch | 592 bytes | manish-31 |
Comments
Comment #1
Zythyr CreditAttribution: Zythyr commentedHelp???
Comment #2
BassPlaya CreditAttribution: BassPlaya commentedI have come up the exact same problem and after a three hours search and trial and error I found a solution.
I have to say that it works for me now on my local install of Drupal 6, so let's hope it's going to do the same thing on the server.
I'm also not really a coder so I'm not sure if I'm doing this correctly. If anyone knows how to do it better, please correct me.
Here's the code you'll have to use and it will do exactly what you want it to do: truncate characters of a replacement pattern for automatic node titles.
The $mystring is something you can name whatever you want but make sure it doesn't conflict with any other string coz I might think that it could.
Comment #3
fagono patch.
Comment #4
mototribe CreditAttribution: mototribe commentedexcellent, that worked for me too (Drupal 7).
Thank you!
Comment #5
giorgio79 CreditAttribution: giorgio79 commentedWould be great to have this as a checkbox option next to the auto title field :)
Similar to #668308: Trim the title to limited amount of characters and add ellipsis
Comment #6
manish-31 CreditAttribution: manish-31 at OpenSense Labs for DrupalFit commentedWith this patch I have restricted the maximum length of the generated title to be 70 characters, which was 255 characters earlier. Please review this patch.
Comment #8
gaurav.kapoor CreditAttribution: gaurav.kapoor commented