Hey there! I'm currently setting up an OS Commerce site for a client for the first time and am having a bit of difficulty. I've already tried asking the folks on their support forum, but they can't offer an answer.

On the index page of the store, my client wanted some welcome text and store info which is defined by a variable known as TEXT_MAIN. She also wants a description for each category on her site. My problem is that OS Commerce is showing TEXT_MAIN on these other pages and then lists the category description below that. Here's some examples:

Main page:
http://onestopmommy.com/osc/index.php

Mattress page (category description comes after the introduction)
http://onestopmommy.com/osc/index.php/cPath/31

How can I get this TEXT_MAIN to only show on the main page? Here's part of the current code for that page....this forum won't let me post the whole code because its so long. I'd appreciate any help on this!

<?php
/*
  $Id: index.php 1739 2007-12-20 00:52:16Z hpdl $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Greenmania Template by www.badeziner.com 
  Released under the GNU General Public License
*/

  require('includes/application_top.php');

// the following cPath references come from application_top.php
  $category_depth = 'top';
  if (isset($cPath) && tep_not_null($cPath)) {
    $categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
    $cateqories_products = tep_db_fetch_array($categories_products_query);
    if ($cateqories_products['total'] > 0) {
      $category_depth = 'products'; // display products
    } else {
      $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
      $category_parent = tep_db_fetch_array($category_parent_query);
      if ($category_parent['total'] > 0) {
        $category_depth = 'nested'; // navigate through the categories
      } else {
        $category_depth = 'products'; // category has no products, but display the 'no products' message
      }
    }
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<meta name="keywords" content="baby, organic, clothing, bedding, toddler clothes, infant clothing, baby clothes, diaper, bedding, duvet cover, sheets, furniture" />
<meta name="description" content="Welcome to One Stop Mommy Organics. We are dedicated to bring you the safest organic bedding, clothes, furniture and toys for your child or baby." />
<meta name="Author" content="badeziner" />
<meta name="Theme" content="Greenmania" />
<meta name="webdesign" content="www.badeziner.com" /></head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<div id="wrapper">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<table width="814" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
	  <td style="background: url(images/template/left_border.gif) repeat-y;width:7px;height:100%;"></td>
		<td colspan="11" bgcolor="F1F9D6">
<!-- body //-->

<table border="0" width="100%" cellspacing="3" cellpadding="3">
  <tr>
<td class="main"><?php echo TEXT_MAIN; ?></td>


<td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
<!-- body_text //-->

    I have no idea what oscommerce is but looking at the links you provided, it looks like the 'cPath' variable is being set. So there should be a default value for the main page, or perhaps no value.

    if ( empty( $cPath ) ) 
    {
    	echo $TEXT_MAIN;
    }
    

    shrug

      Okay, so I changed the code to look like this:

      <td class="main"><?php if ( empty( $cPath ) ) 
      { 
          echo $TEXT_MAIN; 
      } ?></td>

      Did I code it right? When I view that page now, there is just a big empty spot where the introduction should be.

        Hey there! I'm currently setting up an OS Commerce site for a client for the first time and am having a bit of difficulty

        OS Commerce...my condolences. :eek:

        Doesn't oscommerce have templates for each type of file? In other words, you may be able to use a variable specific to the home page or take TEXT_MAIN out of index.php and refer to it it templates instead. Really, this is a specific issue to oscommerce. Sorry they were not helpful.

        Is it too late to switch to Zen Cart? 😃

          Yeah, its pretty late to switch over. My client is anxious to start working on the site herself and this is one of the last things to be done. I'd like to ideally give her both the site introduction and category descriptions if possible.

          On OSCommerce, how it works is there is a main index.php page where the layout is set by coding (this is the one I've been referring to). Then there is an additional index.php page under their languages folder where you actually define what TEXT_MAIN is. I don't think this is necessarily a template problem, but rather an OSCommerce problem in general. If the categories looked at another file besides that index.php for their template, my life would have been a lot simpler.

            I was playing around with the code above and found that if I take away the $ from TEXT_MAIN, that now it is showing properly 😃 Thank you for that code!

            There's just one minor thing to fix now. On the category pages like here:
            http://onestopmommy.com/osc/index.php/cPath/31

            the description doesn't show until way down on the page. Is there a way to pull that up to the top of the page?

              Just echo $cPath

              <td class="main">cPath == <?php echo $cPath; ?></td>

              Then view the main page and see what the result is.

              [edit]Nevermind 🙂[/edit]

                Ah got ya! I just opened a oscommerce project that I suffered with and looked at the code 😃

                I have something like this in my index page

                elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
                //show code for products and such
                } else {
                // show default page (shows the contents of TEXT_MAIN
                }

                Looks like your code has been changed significantly. I guess you need to put some similar logic back in.

                  I have part of the code you mentioned...perhaps you can catch what needs to be fixed. I can't copy the code on this forum because its too big, so I saved it as a text document. You can view it here:
                  http://onestopmommy.com/index.txt

                    I have essentially the same thing except your code doesn't have the TEXT_MAIN constant under the "default" section and mine does.

                    Yours:

                    <?php
                      } else { // default page
                    ?>
                        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                              <tr>
                                <td><?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?></td>
                              </tr>
                    

                    Mine:

                    <?php
                      } else { // default page
                    ?>
                        <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">
                          <tr>
                            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                              <tr>
                                <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
                                <td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_default.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
                          </tr>
                          <tr>
                            <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
                              <tr>
                                <td class="main"><?php echo tep_customer_greeting(); ?></td>
                              </tr>
                              <tr>
                                <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
                              </tr>
                              <tr>
                                <td class="main"><?php echo TEXT_MAIN; ?></td>
                              </tr>

                    Again, notice that my echo TEXT_MAIN is under the else block. I'm pretty sure I never changed the index page (just header/footer etc.) so this must be the oscommerce default.

                      Thank you so much bretticus! Sharing that code gave me some ideas. I've played around with the code a bit and now everything is working great.

                      You can go ahead and close this thread 🙂

                        sakura92983;10879671 wrote:

                        Thank you so much bretticus! Sharing that code gave me some ideas. I've played around with the code a bit and now everything is working great.

                        Excellent!

                        sakura92983;10879671 wrote:

                        You can go ahead and close this thread 🙂

                        It's your thread, I think you have to close it. It's an option under Thread Tools menu.

                          Write a Reply...