PHP Trick for Bloated OpenSource Software">PHP Trick for Bloated OpenSource Software

January 21st, 2008 by Jack Keller

If your any­thing like me noth­ing is great until you’ve hacked it apart. How­ever with Open­Source soft­ware many times your hacks and mods will be over­writ­ten every time you upgrade to the lat­est and great­est. So how can one com­bat this task with lit­tle to no hacks?

First off let me say that I’m not knock­ing any soft­ware here, I know that peo­ple pour hours and hours of their heart and soul into build­ing some­thing that can be used by nearly any­body. But as a sea­soned designer I have to gripe about CSS bloat, it’s every­where, tags nested ten to twenty lev­els deep sometimes.

So if you're using PHP, you can always do what I’ve done using the ob_start method (in fact it’s how I’m build­ing 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 hack­ing core files to an Open­Source appli­ca­tion. The code below is what you want to place before your file starts, or your con­tent area if you’re just look­ing to change some wording.

PHP:

This site was built using the Word­press CMS and care­fully loved with CSS for your view­ing pleasure.

PHP:
  1. // set up an array of words you want to find, then replace
  2. $main­nor­mal = array(
  3. CSS ‘,
  4. CMS ‘,
  5. );
  6.  
  7. $main­cus­tom = array(
  8. ’ <acronym title="Cas­cad­ing Style Sheets">CSS</acronym> ‘,
  9. ’ <acronym title="Con­tent Man­age­ment Sys­tem">CMS</acronym> ‘,
  10. );
  11.  
  12. echo str_replace($main­nor­mal,$main­cus­tom,ob_get_clean());

Sim­ple array in place, if you were only going to replace one word on the site you could just sur­round it with quotes and put it into the echo str_replace func­tion, I find this use­ful to help remove extra classes and ID’s unnec­es­sary to a CMS, makes my job eas­ier as a designer to keep the Stylesheet well formed.

Share?
  • Facebook
  • Design Float
  • del.icio.us
  • StumbleUpon
  • Technorati
  • Digg

Posted in PHP Be the first to comment! »

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