User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,763 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,532 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
May 11th, 2007
Views: 1,708
Okay so I had this need to vary the template layout of an osCommerce theme using its BTS (basic template system) and noticed that unlike standard osCommerce where you can edit each and every individual page to have a unique layout, BTS uses a template system to generate its look. I've ran into this with designing open-realty templates and figured its time to come up with a solution.

The problem for me was that there were places I only wanted Two column layouts on my three column theme I designed and there were places where I wanted flash in the header on some pages but not others. Alternatively I also need some pages to load the third column WITH Ads and others without. Here is what I did;

So how do I solve this little dilemma? Well I had to resort to some PHP to kinda fake it and get the template layout to function as if it were a full blown CMS template engine where I could control how many columns or elements got displayed and where they got displayed. I wrote about doing this in my blog located at http://www.jaredritchey.com where you can download an example osCommerce template and an example Open-Realty template using the same type of configuration.

Here is the code in three parts;
A) Create a file called settings.php for example using the first block of code below. You can remove the (DIR_WS_CATALOG) . if not using this in an oscommerce template.
B) Add the second set of code to your template header.
C) Your files you wish to have loaded

Its that simple. I do provide examples and have no problems sharing it in other forums around the web.

Enjoy!
php Syntax | 5 stars
  1. #### 1 in a settings.php file or some other name of your choice
  2.  
  3. <?php
  4. //echo (DIR_WS_TEMPLATES) . "example.php" ; // BTSv1.5
  5. $P=$_SERVER['REQUEST_URI'];
  6. switch ($P) {
  7.  
  8. // THESE ARE PLACES I WANT THREE COLUMNS WITH BANNERS
  9. case (DIR_WS_CATALOG) . "/login.php";
  10. case (DIR_WS_CATALOG) . "/privacy.php";
  11. $data = (DIR_WS_TEMPLATES) . 'threecolumnads.php';
  12. break;
  13.  
  14. // THESE ARE PLACES I WANT THREE COLUMNS WITH NO ADVERTISING
  15. //case (DIR_WS_CATALOG) . "/index.html" || $P == "/" || "$P" == "/index.php":
  16. case (DIR_WS_CATALOG) . "index.php":
  17. $data = (DIR_WS_TEMPLATES) . 'threecolumn.php';
  18. break;
  19.  
  20. // TWO COLUMNS EVERY WHERE ELSE
  21. default:
  22. $data = (DIR_WS_TEMPLATES) . 'twocolumn.php';
  23. }
  24. ?>
  25.  
  26. #### 2 in your header template somewhere
  27.  
  28. <?php require(DIR_WS_TEMPLATES . 'settings.php'); ?>
  29.  
  30. #### 3 Example threecolumn.php
  31. <div id="maincolumn" >
  32. <div class="inside">
  33. <!-- content //-->
  34. <?php require (bts_select ('content')); // BTSv1.5 ?>
  35. <!-- content_eof //-->
  36. </div>
  37. </div>
  38. <div id="rightcolumn">
  39. <div class="inside">
  40. <!-- right_navigation //-->
  41. <?php require(bts_select('column', 'column_right.php')); // BTSv1.5 ?>
  42. <!-- right_navigation_eof //-->
  43. </div>
  44. <div class="adzone">
  45. //advertisements here
  46. </div>
  47. </div>
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 3:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC