Help - Search - Members - Calendar
Full Version: Force first-letter uppercase
Movable Type Community Forum > Additional Resources > Tips and Tricks
losmadden
There are ways to dirify a tag, to uppper_case it, and to lower_case it. Is there any way to force the first letter to be uppercase, but leave the rest of the word or phrase in lowercase? Make it like a sentence? I want to force conformity in some commenter values, some of which use only lowercase, some of which use sentence-capitalization, some of which might possibly use all caps.

Any ideas?
insameluise
Eva Jagt Zwei Boxkämpfer Quer Durch Sylt

"capitalize" : every word begins in Uppercase

"uppercase": all word uppercase

CODE
<p style="text-transform : capitalize">Eva jagt zwei Boxkämpfer quer durch Sylt</p>
gvtexas
You can achieve sentence case structure with the DirifyPlus plugin.

Cheers,
Gary
kadyellebee
I was thinking that the Change Text Case plugin might do what you want, but now that I look at it closer, I'm not sure. That would be a nice addition to that plugin, though, so maybe let the author of the plugin know? smile.gif

Kristine
losmadden
Thank you for the suggestions. From what I can tell, Dirifyplus comes closest (along with the CSS transformation) to doing what I want, but it seems to want to capitalize the first letter of every word. I don't see a way to let a phrase have just its first word capitalized. I think it will be good enough for now though. Thanks.
pixelmod
Hello (maybe a little late).

QUOTE
Is there any way to force the first letter to be uppercase, but leave the rest of the word or phrase in lowercase?

I spent last weekend trying to resolve this problem. Searching here, there,, I found this 2 modifiers:

<$mt:PageTitle$ capitalize="1"> -> modifies the first char of each word of the phrase to Uppercase
<$mt:PageTitle$ upper_case="1"> -> modifies all chars the phrase to Uppercase

Then I discovered that if the site is published dynamically in php, php code can be inserted into the templates.

So, example:
CODE
<h1 id="page-title" class="asset-name"> <?php $title = '<$mt:PageTitle$>';echo ucfirst($title);?></h1>
--> Only first letter of title Uppercase.

But for the search result pages, whose URL is as follows: mt-search.cgi?blog_id=4&tag=tag&limit=20

the previous php code doesn´t works.. so investigating some javascript, I found this solution:
CODE
<h2 class="asset-name entry-title"><a href="<$mt:EntryPermalink$>" rel="bookmark"><$mt:EntryTitle$></a></h2>
            <script type="text/javascript">
            //<![CDATA[
               var x = document.getElementsByTagName('h2');
                
               for (var i=0;i<=x.length-1;i++)
               {
                  if (x[i].innerHTML == '<a href="http://domain.net/site-path/<$mt:EntryTitle$>/" rel="bookmark"><$mt:EntryTitle$></a>') {
                  
                     var newh2 = document.createElement("h2");
                    
                     newh2.className = "asset-name";
                    
                     var hyperlink = document.createElement("a");
                    
                     hyperlink.setAttribute("href", "<$mt:EntryPermalink$>");
                    
                     hyperlink.setAttribute("rel", "bookmark");
                    
                     var title = '<$mt:EntryTitle$>';
                    
                     title = title.slice(0,1).toUpperCase() + title.slice(1);
                    
                     var text = document.createTextNode(title);
                    
                     hyperlink.appendChild(text);
                    
                     newh2.appendChild(hyperlink);
                    
                     var previoush2 = x[i];
                    
                     previoush2.parentNode.replaceChild(newh2, previoush2);
                  }
               }
               //]]>
         </script>


regards




This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.