ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

make segment string uppercase

July 30, 2010 8:52pm

Subscribe [3]
  • #1 / Jul 30, 2010 8:52pm

    Tried searching the forums but did not find anything relating to my question (sorry if I missed it)

    Could someone tell me (if it is possible) how to take the segment_1 and make it uppercase?

    calling for {segment_1} in my template displays about ; I would like it to show ABOUT, or even About

    Thanks in advance!

  • #2 / Jul 30, 2010 9:34pm

    Lisa Wess

    20502 posts

    Welcome to the forums!  I’ve moved this to the CodeShare Corner.

    How about using a CSS text transform? You can read about it on w3schools.com.

  • #3 / Jul 31, 2010 1:14am

    trenchard

    128 posts

    CSS will work or you can use PHP (process on output) in the template…

    <?php
    $str = "{segment_2}";
    $str = strtoupper($str);
    echo $str;
    ?>
  • #4 / Jul 31, 2010 1:32am

    CSS will work or you can use PHP (process on output) in the template…

    <?php
    $str = "{segment_2}";
    $str = strtoupper($str);
    echo $str;
    ?>

    Excellent! Worked perfectly.

  • #5 / Jul 31, 2010 11:57am

    trenchard

    128 posts

    You can actually parse PHP on input also if you need to since the segment variable will be parsed very early.

  • #6 / Nov 22, 2012 9:06am

    Dotwebs

    13 posts

    I found this while searching for the same. I’ve taken Lisa’s advice and used the css property in a span because I wanted the segment to appear in the middle of a sentence. This is a better solution if you don’t want to use PHP in your templates.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases