Black Belt
- Join Date:
- Jul 2005
- Location:
- Upstate NY
- Posts:
- 21,876
- Plugin Contributions:
- 8
A better way of dealing with large define() statements?
I came across this tip on a site while checking a now obsolete thread. The site is about seven years old and mostly or completely irrelevant to current Zen Cart, but this seems like it could be useful and worth preserving. I haven't tried it yet.
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 b*tch 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(); ?>