PHP Trick for Bloated OpenSource Software

January 21st, 2008 by Jack Keller

If your anything like me nothing is great until you’ve hacked it apart. However with OpenSource software many times your hacks and mods will be overwritten every time you upgrade to the latest and greatest. So how can one combat this task with little to no hacks?

First off let me say that I’m not knocking any software here, I know that people pour hours and hours of their heart and soul into building something that can be used by nearly anybody. But as a seasoned designer I have to gripe about CSS bloat, it’s everywhere, tags nested ten to twenty levels deep sometimes.

So if your using PHP, you can always do what I’ve done using the ob_start method (in fact it’s how I’m building the Acronyms for this site currently).

So if you want to change a few things around, this is a pretty good method to help you avoid hacking core files to an OpenSource application. The code below is what you want to place before your file starts, or your content area if you’re just looking to change some wording.

PHP:

This site was built using the Wordpress CMS and carefully loved with CSS for your viewing pleasure.

PHP:
  1. // set up an array of words you want to find, then replace
  2. $mainnormal = array(
  3. ’ CSS ‘,
  4. ’ CMS ‘,
  5. );
  6.  
  7. $maincustom = array(
  8. ’ <acronym title=“Cascading Style Sheets”>CSS</acronym> ‘,
  9. ’ <acronym title=“Content Management System”>CMS</acronym> ‘,
  10. );
  11.  
  12. echo str_replace($mainnormal,$maincustom,ob_get_clean());

Simple array in place, if you were only going to replace one word on the site you could just surround it with quotes and put it into the echo str_replace function, I find this useful to help remove extra classes and ID’s unnecessary to a CMS, makes my job easier as a designer to keep the Stylesheet well formed.

Share? These icons link to social bookmarking sites where readers can share and discover new web pages.
  • bodytext
  • StumbleUpon
  • del.icio.us
  • NewsVine
  • Technorati
  • TwitThis
  • Google
  • Facebook
  • description

Posted in PHP

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About media|extranet

We're a group of industry professionals who would like to give a little bit back to the community. Although we've just begun, we plan to do some write-ups on Advertising, Marketing, Development (.NET, PHP, Flash, Flex, AIR, JavaScript Frameworks, etc.) and Copywriting. Visit our contact section if you would like to see us cover something that we're not. The links below are for our writers, visit them directly if you have a project in mind that could utilize their talents.

Visit Snackbox Labs Visit ☆dup