Forcing field value to render as UPPERCASE

12 posts by 3 authors in: Forums > CMS Builder
Last Post: February 15, 2010   (RSS)

Hi all,

I’d like to convert all the characters in a field called "title" to UPPER CASE and then echo the UPPERCASE version.

I found strtoupper but can’t seem to implement it correctly.

Any insights?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Forcing field value to render as UPPERCASE

By Damon - January 30, 2010

What about using CSS?

text-transform: uppercase;
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [gkornbluth] Forcing field value to render as UPPERCASE

By Damon - February 1, 2010

Hi,

As far as I'm aware, the styling for RSS feeds is done in the readers, either web or pc/mac based, not in the actually XML.

For an RSS feed, you are better off using the strtoupper function:

<?php
echo strtoupper("Hello WORLD!");
?>

Output:

HELLO WORLD!
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Forcing field value to render as UPPERCASE

Damon,

I appreciate the feedback.

Since the original code in the rss feed was

<title><?php echo htmlspecialchars($record['title']) ?></title>

I haven't been able to figure out the correct syntax for incorporating "strtoupper" into that line of code.

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Forcing field value to render as UPPERCASE

By Damon - February 1, 2010

How about this:

<?php $title = htmlspecialchars($record['title']; ?>
<title><?php echo strtoupper($title); ?></title>


I haven't tested this out but it looks good to me.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Forcing field value to render as UPPERCASE

Thanks again Damon,

Just tried it and the recommended change renders a blank page.

Here's what I started with:

<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "/hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/lib/viewer_functions.php";

list($current_eventsRecords, $current_eventsMetaData) = getRecords(array(
'tableName' => 'current_events',
'limit' => '2',
));

?>

<rss version="2.0">
<channel>

<title>ARTISTS OF PALM BEACH COUNTY - HAPPENING NOW RSS FEED</title>
<link>http://www.artistsofpalmbeachcounty.org/events.php</link>
<description>Arts Events Worth Knowing About</description>
<image>
<title>This is my Image</title>
<url>http://www.artistsofpalmbeachcounty.org/images/APBC-LOGO.png</url>
<link>http://www.artistsofpalmbeachcounty.org</link>
</image>
<pubDate><?php echo date('r'); ?></pubDate>
<language>en-us</language>

<?php foreach ($current_eventsRecords as $record): ?>
<item>
<title><?php echo htmlspecialchars($record['title']) ?></title>
<link>http://www.artistsofpalmbeachcounty.org<?php echo $record['_link'] ?></link>
<description><?php echo htmlspecialchars($record['rss_description']); ?></description>
<pubDate><?php echo date("r", strtotime($record['date'])) ?></pubDate>
<guid isPermaLink="true">http://www.artistsofpalmbeachcounty.org<?php echo $record['_link'] ?></guid>
</item>
<?php endforeach ?>

</channel>
</rss>


And here's the page with your recommendation:

<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php

require_once "/hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/cmsAdmin/lib/viewer_functions.php";

list($current_eventsRecords, $current_eventsMetaData) = getRecords(array(
'tableName' => 'current_events',
'limit' => '2',
));

?>

<rss version="2.0">
<channel>

<title>ARTISTS OF PALM BEACH COUNTY - HAPPENING NOW RSS FEED</title>
<link>http://www.artistsofpalmbeachcounty.org/events.php</link>
<description>Arts Events Worth Knowing About</description>
<image>
<title>This is my Image</title>
<url>http://www.artistsofpalmbeachcounty.org/images/APBC-LOGO.png</url>
<link>http://www.artistsofpalmbeachcounty.org</link>
</image>
<pubDate><?php echo date('r'); ?></pubDate>
<language>en-us</language>

<?php foreach ($current_eventsRecords as $record): ?>
<item>
<?php $title = htmlspecialchars($record['title']; ?>
<title><?php echo strtoupper($title); ?></title>
<link>http://www.artistsofpalmbeachcounty.org<?php echo $record['_link'] ?></link>
<description><?php echo htmlspecialchars($record['rss_description']); ?></description>
<pubDate><?php echo date("r", strtotime($record['date'])) ?></pubDate>
<guid isPermaLink="true">http://www.artistsofpalmbeachcounty.org<?php echo $record['_link'] ?></guid>
</item>
<?php endforeach ?>

</channel>
</rss>


The link to the working RSS feed is http://artistsofpalmbeachcounty.org/rss/happening-now-rss.xml.php

Best,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Forcing field value to render as UPPERCASE

By Damon - February 1, 2010

Sorry, I missed a closing bracket:

<?php $title = htmlspecialchars($record['title']); ?>
<title><?php echo strtoupper($title); ?></title>

I tested this out and it works. Next time, I will write my code in Komodo Edit and it will underline any syntax errors and save me lots of head scratching. :)
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Forcing field value to render as UPPERCASE

Sorry. I didn't catch it either.

As they say on the other side of the pond...

It works a treat!

Komodo Edit looks interesting. Thanks for that too.

Best,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [Damon] Forcing field value to render as UPPERCASE

Hi Damon,

Thanks for the implementation tips. I've been using it a lot.

One question...

If I wanted to implement strtoupper in a date to force any text characters into upper case, what syntax would I use?

Here's what I have now.

<?php echo date("D, M jS, Y", strtotime($e_blastRecord['press_release_publish_date'])) ?>

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php