justin's zen cart schtick

A better way of dealing with large define() statements

Many language files for static pages have the basic format of: <?php define('NAVBAR_TITLE', 'Page Title'); define('HEADING_TITLE', 'Page Heading'); define('TEXT_INFORMATION', 'Lots and lots of body text.'); ?>

This makes the TEXT_INFORMATION a bitch to modify. Also if you're simply cutting and pasting a large amount of HTML, it means that you have to go through and make sure all of your single quotes and backslashes are escaped. Also if you're using an editor like Homesite, it won't show any color coding for any HTML tags you have. This sucks.

A better way to do it is like this: <?php define('NAVBAR_TITLE', 'Page Title'); define('HEADING_TITLE', 'Page Heading'); ob_start(); ?> Lots and lots of free body text. <?php define('TEXT_INFORMATION', ob_get_contents()); @ob_end_clean(); ?>


lifefeed@gmail.com    »«    more zencart goodness    »«    home