drupal_get_title() automatically capitalizes the page title. that's annoying in some cases. this should be a theme decision. for an example of why that stinks, see http://drupal.org/cvs. The title is Cvs. Feh

CommentFileSizeAuthor
#5 no_ucfirst_title.patch434 bytesChris Johnson

Comments

ax’s picture

kyber’s picture

I agree. also screwed up my bug report where I started title with a method name.
I stripped it from parts of our system a while ago since it was messing with titles of poems where users had deliberately not capitalized title for stylistic reasons of their own.
Just a pointless feature, IMO. If people want capitalization in a title, they can darn well press the shift key.

skip’s picture

double plus 1.

Either let the posting user capitalize, or have it in the CSS.

gábor hojtsy’s picture

The automatic capitalization is in place so pages can have nice default titles. A lot of pages use their default titles derived from the URL's registered menu item's title, which is completely lowercase most of the time... Still I would also like to see the uppercasing delegated to the theme, so people can decide themselfs... This is a presentation issue anyway...

I am hopeful that if someone submits a proper patch, Dries will not complain much :)

Chris Johnson’s picture

Assigned: Unassigned » Chris Johnson
StatusFileSize
new434 bytes

Patch attached.

dries’s picture

That patch makes the titles look ugly - see Goba's explanation. A proper patch that updates the theme system (themes) is required for this to be evaluated.

On a related note, how about capitalizing the breadcrumb trails or delegating capitalization thereof to the theme system (themes)?

gábor hojtsy’s picture

In reply to the related note from Dries, since I am already using a hacked up theme which capitalizes the breadcrumb items, I am all for capitalizing them too :)

skip’s picture

You could have it both ways by adding an 'id' attribute to the tag that holds the title (and the breadcrumb), and then 'text-transform: capitalize;' in the theme's CSS file.

Although... I guess that would capitalize every word in the title/breadcrumb...

How about having drupal_get_title() put a span around the first word of the title (w/ an id="capitalize") and then adding the text-transform CSS to the drupal.css file. Then, none of the themes would have to be messed with... and it can still be overridden on a theme-by-theme basis.

I can write up a patch if y'all like that idea.

gábor hojtsy’s picture

Please look for all ucfirst() usages!

dries’s picture

I think the majority of the people want to capitalize the first work of their page titles and breadcrumb trail so IMO, that should be the default behavior. No?

gábor hojtsy’s picture

Yess...

Chris Johnson’s picture

Majority of which people, Dries?

I don't want Drupal core automatically capitalizing any of my text (or any other unasked for transformation).

Core should provide services, themes should provide viewing styles, and site admins and users should choose which transforms (e.g. HTML filters, text transforms, spelling correction, etc.) they want applied to their content. Otherwise, we might as well sprinkle HTML through the core and make database changes in the themes. What's the point of having logical architecture layers (separation) if one doesn't stick to it?

As for where ucfirst is used -- from last night's CVS:

64 host9:~...cms/dev-drupal> fgrep -rl ucfirst *
includes/menu.inc
modules/archive.module
modules/help.module
modules/user.module
modules/title.module
modules/tracker.module

themes/xtemplate/xtemplate.theme

dries’s picture

What I said (or meant to say) is: the behavior should be themeable but we should try to choose a sensible default -- we have defaults for any theme function. I think the default behavior should capitalize titles and breadcrumb trails.

skip’s picture

I agree that the default should be uppercase... I just think that it should be done in a way that can be undone.

Using CSS (rather than ucfirst) would give admins the option of changing the default behavior, and it wouldn't be very complicated to implement.

>>What I said (or meant to say) is: the behavior should be themeable
>>but we should try to choose a sensible default -- we have defaults
>>for any theme function. I think the default behavior should
>>capitalize titles and breadcrumb trails.

dries’s picture

But how to do it using CSS? Wrapping the first word in <span class="first-word"></span> looks somewhat clumsy to me.

skip’s picture

Well, I did a bit of experimenting (w/ my CSS book in hand)... and it "should" be easily done with the :first-letter pseudo class.

i.e. #pageTitle:first-letter { text-transform: capitalize; }

but... considering the level of support for pseudo classes right now, I don't think that's a reliable option.
My brief test with Safari mangled it up pretty bad.

I don't think putting the span in there is that bad (for the flexibility it offers), but that's just me.

dries’s picture

Beside CSS pseudo-classes not being widely supported, it degrades not as nice as using ucfirst(). A detail, I know.

moshe weitzman’s picture

wrapping the first word in a span seems reasonably elegant to me. i can't think of a better solution.

axel’s picture

Sadly, this thing move to 4.4 release. +1 for removing ucfirst if it not removed while.

For my site I try workaround with setting proper locale for script. For example for Russian environment:

setlocale(LC_ALL, "ru_RU.utf8")

...but later me simply remove ucfirst() from common.inc and problem with titles disappear. Let's users more freedom with choice Capitalize or not their posts.

killes@www.drop.org’s picture

Drupal should not interfere with user input without any feedback. If a site admin wants users to capitalize the first word in their postings, that admin should create a module that implements the _nodeapi("validate") hook and rejects improper formatted postings. In other words: ucfirst should be removed.

dries’s picture

I'm OK with removing instances of ucfirst() (though that does not seems to solve the themability issue).

dries’s picture

jonbob’s picture

This is now done via CSS, so the theme can override this behavior.

Anonymous’s picture