Why: We have only added a stylesheet class “main-content” - to allow us to give the main content area some style. Note that the file index.php requires you to do this in three places! Page 9 And finally, remove this (found immediately before the ending tag):
Why: We will be able to replicate this (if required) using the file stylesheet.css You must do this for each and every main .php file. Save and upload them. Don't worry too much about the reasons why we made those changes – I'll be going into more detail about that later on in this book. Helping You: If you don't have the time to make these changes, please download the file http://octave.netfirms.com/samples/pages.zip where the changes have been made for you as required. Overwrite the existing files you have in your Store with the files in the .zip – it would obviously be better for you to do the changes yourself as you will become more familiar with Oscommerce code by doing it yourself. Now you have a very poorly looking Store, but we will remedy this, don't worry about it. As of right now, your Store should look like this: Page 10 Reducing the Width of each page to fit our design Thinking of a Magazine page, it's about A4 paper size, so let's add in some code to fix the Store Width and to allow us to center the shop into the middle of the page. Open up: /includes/header.php and add the following code right at the very start of the file:
Open up: /includes/footer.php and add the following code right at the very end of the file:
What we have said using this code is: 1. Put the whole contents of the Store into a table fixed at 760 pixels wide (this is approximately the width of an A4 page) 2. Align it to the center of the page. Save those two files and upload them into the correct directory. Your site should now look like this: Page 11 Page 12 Making the Left Hand Column Wider What we now need to do is make our Left Hand Side Column a little wider, as you can see the Magazine Advert Left Column is approximately ¼ the width of the full page. Remember that we have set our page to 760 pixels wide, so ¼ of that is 190. You should open up: /includes/application_top.php Amend the following code (approx line 63): define('BOX_WIDTH', 150); // how wide the boxes should be in pixels (default: 125) to this: define('BOX_WIDTH', 190); // how wide the boxes should be in pixels (default: 125) Save the file and upload it to your Store. Whilst we are looking at the Left Hand Side Column, let's also give it some style using our Stylesheet. If you look back through this eBook, you'll see that we amended the Left Hand Side Column code to add in an extra stylesheet call: left-column Open up stylesheet.css in your favourite text editor, and add the following code: .left-column { background: #cccccc; padding: 10px; } Note that whenever you create a style in your HTML code (eg class=”leftcolumn”) then you must use the exact same name in your stylesheet, but put a period (dot, full stop etc) in front of it, like this: .left-column Save the file [ stylesheet.css ] and upload. Refresh your Store a few times for those stylesheet changes to kick in. Your site should now look like this: Page 13 As you can see the changes we made to the stylesheet have given our Left Hand Column a background colour! Easy, isn't it :) However, because of the way that Oscommerce is coded, the InfoBoxes (example categories.php, manufacturers.php etc) all over-ride the Left Hand Column background that we just made so they still look quite awful :( But it's not a major problem and is something we will amend very shortly. We are doing pretty well so far! Let's have a Pit Stop. Time for a coffee and a recap of what we have done so far. We've made a lot of code changes • Removed the Right Hand Side Column • Removed some unwanted Code • Added in some extra Code to allow us to set style • Made the Shop a fixed width and horizontally centered it • Changed a setting in the stylesheet.css to give the Left Column some style. We actually haven't done all that much to be honest – but you can already see that it is starting to look not so like Oscommerce! Good work so far! What's next? Page 14 Recoding the InfoBoxes Let's start changing some code to allow us to give the side InfoBoxes some style! The problem here is that we need to make our “side” InfoBoxes differently to our other InfoBoxes (eg “New Products for...” box). This is pretty easy :), all you need to do is open up: /includes/classes/boxes.php And add the following code at the very end of the file before the ?> tag: class SideinfoBoxHeading extends tableBox { function SideinfoBoxHeading($contents, $left_corner = true, $right_corner = true, $right_arrow = false) { $this->table_cellpadding = '0'; $left_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_left.gif'); if ($right_arrow == true) { $right_arrow = '' . $contents[0] ['text'] . ' »'; } else { $right_arrow = $contents[0]['text']; } $right_corner = tep_image(DIR_WS_IMAGES . 'infobox/corner_right.gif'); $info_box_contents = array(); $info_box_contents[] = array('params' => 'width="100%" class="SideinfoBoxHeading"', 'text' => $right_arrow); $this->tableBox($info_box_contents, true); } } Save the file. Page 15 Now add the following code to the exact same file, again making sure you add it directly before the final ?> tag: class SideinfoBox extends tableBox { function SideinfoBox($contents) { $info_box_contents = array(); $info_box_contents[] = array('text' => $this>SideinfoBoxContents($contents)); $this->table_cellpadding = '0'; $this->table_parameters = 'class="SideinfoBox"'; $this->tableBox($info_box_contents, true); } function SideinfoBoxContents($contents) { $this->table_cellpadding = '0'; $this->table_parameters = 'class="SideinfoBoxContents"'; $info_box_contents = array(); $info_box_contents[] = array(array('text' => tep_draw_separator('pixel_trans.gif', '100%', '1'))); for ($i=0, $n=sizeof($contents); $i<$n; $i++) { $info_box_contents[] = array(array('align' => (isset($contents[$i]['align']) ? $contents[$i] ['align'] : ''), 'form' => (isset($contents[$i]['form']) ? $contents[$i]['form'] : ''), 'params' => 'class="boxText"', 'text' => (isset($contents[$i]['text']) ? $contents[$i]['text'] : ''))); } $info_box_contents[] = array(array('text' => tep_draw_separator('pixel_trans.gif', '100%', '1'))); return $this->tableBox($info_box_contents); } } What we have done here is create an extra portion of code to allow us to differentiate between a “side” infoBox and a “normal” infoBox. Page 16 Now you must open up each of the infoBox files found in /includes/boxes/ and change the following code: new infoBoxHeading to: new SideinfoBoxHeading And: new infoBox to: new SideinfoBox We do this in order to tell our InfoBoxes to create themselves using the new code we just added to /includes/classes/boxes.php Once you have done that, your site should look like this: However, something has gone wrong as the Headings of our side InfoBoxes have lost their style !! In fact not only the Heading of each InfoBox has lost it's style, but also the Contents of each InfoBox as well !!! Page 17 Don't worry, it's nothing major, this is exactly what we wanted to happen as we will now look to amend both the Heading and Content Area of the InfoBoxes using the file stylesheet.css. Giving the InfoBoxes some Style Now we open up stylesheet.css and amend the style which control how the side InfoBoxes look. Simply add the following piece of code: .SideinfoBox { background: #cccccc; } Why: This is to match the colour of the Left Hand Column Background. Now find: .boxText { font-family: Verdana, Arial, sans-serif; font-size: 10px; } Change it to: .boxText { font-family: Verdana, Arial, sans-serif; } Why: We will be controlling the font size elsewhere in the stylesheet :) Now add the following code (to stylesheet.css): TD.SideinfoBoxHeading { font-family: Verdana, Arial, sans-serif; font-size: 12px; font-weight: bold; background: #cccccc; color: #000000; font-variant: small-caps; } Also add the following code (to stylesheet.css): .SideinfoBoxContents { background: transparent; font-family: Verdana, Arial, sans-serif; font-size: 0.8em; line-height: 1.5; } Page 18 After making these changes, your site should now look like this: As you can see, making the changes in the stylesheet has made our left hand column fall into place :) The only thing in there that looks not so good is the small “magnifying glass” image that powers the Search InfoBox. Don't worry about this for now, as we will be removing the Search InfoBox into the Header Area a little later on in this tutorial. At least now we have made our Left Hand Side Column look really great! We are slowly but surely getting there :) Page 19 Giving the Main Contents Area some style Let's now look at the Main Content Area. We need to give it a bit of room to breath and also a background colour. Open up stylesheet.css once again, and add the following code: .main-content { background: #fafafa; padding: 10px; } This gives our Main Content Area (remember we set it up to use the stylesheet class “main-content” when we made the changes to all of our main .php files) some padding (room for it to breath) and a nice light grey background colour. Easy, isn't it ? :) And now your Site should look exactly like this: Page 20 Recap Let's take another Pit Stop. We're doing well so far, though the Header Area still looks very much like Standard Oscommerce :( Let's change that next, but first it's time for recap and a coffee. What have we done so far; We've made a lot of code changes: • Removed the Right Hand Side Column • Removed some unwanted Code • Added in some extra Code to allow us to set style • Made the Shop a fixed width and horizontally centered it • Changed a setting in the stylesheet.css to give the Left Column some style. Since our last Pit Stop, we've also done the following: • Added some new code to allow us to change "side" InfoBoxes without changing any other InfoBoxes • Made subtle changes to each "side" InfoBox file to allow the use of our new code • Added extra Stylesheet classes to give those new InfoBoxes some style • Given the Main Content Area some space! It's starting to look pretty good! Page 21 Changing the Header Area to our own design Let's take it one step further away from standard Oscommerce by adding in our own Header Graphic. What you need to do is make (or find) yourself a Graphic to use. It needs to be 760 pixels wide (remember this is the width of our site that we set in includes/application_top.php). I got a Graphic from www.istockphoto.com you can see a small version of it here: We could simply use it as it is now: Save the image into the /images/ folder as filename: logo.jpg Then open up the file: includes/header.php and find this code:
' . tep_image (DIR_WS_IMAGES . 'oscommerce.gif', 'osCommerce') . ''; ?> ' . tep_image(DIR_WS_IMAGES . 'header_account.gif', HEADER_TITLE_MY_ACCOUNT) . '  ' . tep_image (DIR_WS_IMAGES . 'header_cart.gif', HEADER_TITLE_CART_CONTENTS) . '  ' . tep_image(DIR_WS_IMAGES . 'header_checkout.gif', HEADER_TITLE_CHECKOUT) . ''; ?>  
Page 22 Change it to this:
' . tep_image(DIR_WS_IMAGES . 'logo.jpg', STORE_NAME) . ''; ?>
Which would make our Store look like this: But, in my opinion that makes the Header Area look too “blocky”. Also, note that the Breadcrumb still looks very “Oscommerce” - don't get concerned about this as we will be amending this very shortly! :) Page 23 Let's make some subtle changes to the Header Graphic (just to make it look more pleasant): 1. Cut around a portion of the SunFlower and give it the same colour background as the Left Column. (This will give the effect of the Flower “bleeding” into the column). 2. Put on some Text (perhaps our Stores strap-line) 3. Put on a small Logo 4. Create an area for our “Breadcrumb” element (see below) Once you have made these changes, you should save the new Image as logo.jpg into the /images/ directory. You are basically overwriting that awful blocky image that we started with. Now the Header Area looks like this: Which looks much better! Of course, when you make new designs, you might decide to do none of these things to the Header Graphic! It's up to you, and your choice should be based on what you think looks right for the products or services you are selling.. If you are not much good at graphics then I recommend polishmypixels.com who will be able to make you a great Logo or Graphic designed to your requirements! Anyway, once you have a graphic in place, we need to put in some extra elements to overlay it...the extra elements we want to use within the Header are: 1. The Search InfoBox 2. The Languages Flags InfoBox 3. The Store “Breadcrumb” (top >> catalog etc etc) Because of the way that Oscommerce is coded it isn't possible to just overlay Page 24 these directly on top of the Image we created. So what we must do is decide whereabouts we want to place those 3 elements. I will create a simple graphic to show you where I want my elements... Remember this is simply a graphic made by me to show you the approximate positions where I want my elements. You can see that what I am trying to achieve is; 1. 2. 3. 4. Remove the Grey & White Breadcrumb. Add in a black text Breadcrumb Add in the languages flags (near the small logo) Add in a Search InfoBox in the top right hand corner of our page We now need to to do for real! It's pretty straightforward, basically all I need to do is slice up the completed Header Graphic up appropriately (see the illustration below). To do something like this, does take some graphics and HTML skill, but I will try to explain exactly what I have done. Page 25 Graphics Changes: I have sliced the graphic into 5 parts: logo_1.jpg (the main sunflower area) logo_2.jpg (a portion of sky that is large enough [width: 455px and height: 79px] to hold the Search InfoBoxes logo_3.jpg (another portion of sky that is large enough [width: 455px and height: 78px] to hold the languages flags. logo_4.jpg (the strapline and logo image) logo_5.jpg (an area of the image which will hold the breadcrumb) I saved all of these new graphic slices into the /images/ directory, ready for use! Then you have to build a HTML table to contain your graphic slices...this is intermediate HTML skill – if you are uncertain how to create a table, then you should take a look at www.htmlgoodies.com which has a number of great tutorials! The actual HTML code for the table we need to use on this design is:
 
You will see that the table does not include all of the slices we made as simple graphic tags “