Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
My content type has first name and surname. The title should be "[firstname] [surname]". First name is optional. If first name is left out there is whitespace before the surname. It would be awesome if there was a checkbox to trim()
the automatically generated node title without having to enter php.
Comment | File | Size | Author |
---|---|---|---|
#3 | issue-1166594-3-trim-node-title.patch | 375 bytes | mr.york |
Comments
Comment #1
jcarlson34 CreditAttribution: jcarlson34 commented+1
I have a similar issue with [firstname] [lastname] [suffix]
Since the suffix doesn't often exist, I end up with a lot of Jane Doe{space} in my titles. The
trim()
command does fix this issue.I haven't learned how to patch for git yet but here's the simple fix on line 138 (just put trim around the $output variable in auto_nodetitle.module):
Comment #2
rwilson0429 CreditAttribution: rwilson0429 commentedThanks, the trim function worked for me for my current specific case. To the extent that trim () only removes whitespaces and other predefined characters from both sides of a string, whenever the pattern includes empty fields in the middle of the pattern, the problem will persist. It is not practical to make all of the fields used in the replacement pattern a required field. Is there a way to trim all fields in the pattern before the result is returned?
Comment #3
mr.york CreditAttribution: mr.york commentedPatch added.
Comment #4
mglamanWorked as expected. Changed title. I don't think this should be an "option" but something it should just do as pure cleanup once processed.
Comment #5
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedPatch is working as designed
Comment #7
gaurav.kapoor CreditAttribution: gaurav.kapoor at OpenSense Labs commented