IPB

Welcome Guest ( Log In | Register )

Movable Type

We're moving to movabletype.org!

At long last, we're moving to forums powered by, well, Movable Type itself. You'll want to bookmark http://forums.movabletype.org/ for future reference, and in the meantime you can view these old forums as a read-only archive of past posts. Thanks for being part of the community!

> Force first-letter uppercase, not dirify, not upper_case, not...
losmadden
post Jun 28 2003, 10:19 AM
Post #1





Group: Members
Posts: 115
Joined: 6-February 03
From: Montevideo, Uruguay
Member No.: 7,622



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?
Go to the top of the page
 
+Quote Post
 
Start new topic
Replies
pixelmod
post Jan 11 2009, 04:28 PM
Post #2





Group: Members
Posts: 46
Joined: 2-February 08
Member No.: 52,314



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




Go to the top of the page
 
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 11.25.09 - 01:45 AM