Bug #16956
closedRedundant comma in label_alt_force
0%
Description
If there ist activate the "label_alt_force" in tt_content [ctrl] with eg this label_alt "title, subtitle", and the subtitle is empty, the result in db_list.php is
MyTitle,
Is the title and the subtitle empty the result is only a comma
,
i have written a patch in
t3lib/class.t3lib_befunc.php
function: getRecordTitle
line:1848
if ($TCA[$table]['ctrl']['label_alt_force'])
// PATCH begin
{
foreach($tA as $key => $value){
if($value != ''){
$tATmp .= $value.', ';
}
}
$t = substr($tATmp,0,-2);
}
// PATCH end
(issue imported from #M4943)
Files
Updated by Thomas Hempel about 17 years ago
Hi,
I have added a new patch which is a bit cleaner in my eyes. Anyway, I'm not sure what the normal bevahior should be.
I think it makes only sense if the comma is removed if it is the last one. All other commas should be kept because it will be very hard to determine in which colume is empty in a dataset.
username, email, name, whatever
username, email, name
username, , name, whatever
Any recommendations?
Greets,
Thomas
P.S.: The patch only removes empty string from the list of labels!
Updated by Julian Kleinhans about 17 years ago
example:
label = title
label_alt = subtitle
label_alt_force = 1
in your patch, the problem is, when a record has a subtitle but no title, the result is
, mySubtitle
correct is only the subtitle without a comma before when there is no title
Updated by David Bruehlmeier about 17 years ago
Hi,
it's debatable if this is really a bug or a feature... Quote from the Core API doc:
"label_alt_force: If set, then the "label_alt" fields are always shown in the title separated by comma."
That's exactly what the function does. But I agree that the result is not very nice and probably not what a user might expect to see.
The attached patch (patch_bug_0004943.txt) makes sure that only values from fields which are not empty are displayed, separated by comma. Thus, no "redundant" commas anymore! :-)
regards,
Dave
Updated by Ingmar Schlecht about 17 years ago
Thomas, can you take care of this and send one of the patches as an RFC to the core list?
Thanks!
- Ingmar
Updated by Thomas Hempel about 17 years ago
Commited to trunk in SVN.
Greets,
Thomas