Wolfgang Posted July 17, 2003 Share Posted July 17, 2003 Hello Brenden, how I can change other php-sites (e.g. allprods.php, ...) to the Template sytem? thx Wolfgang Quote Link to comment Share on other sites More sharing options...
Brenden Posted July 17, 2003 Share Posted July 17, 2003 Hi Wolf Gang, Each page has been split into 3 parts. Application Logic File, Template File, Content File. The 1st part, which is located in the catalog/ directory contains the application logic. This file is usually made by deleting everything between the last $breadcrumb->add statement and require(DIR_WS_INCLUDES . 'application_bottom.php'); and then adding 2 lines. These 1st of these 2 lines tells osCommerce what file is to be used for the content and the second line tells osCommerce what template file to use. For allprods.php this would look like this: <?php /* $Id: allprods.php,v 1.7 2002/12/02 osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2002 osCommerce Copyright (c) 2002 HMCservices Released under the GNU General Public License */ require('includes/application_top.php'); include(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ALLPRODS); // Set number of columns in listing define ('NR_COLUMNS', 1); // $breadcrumb->add(HEADING_TITLE, tep_href_link(FILENAME_ALLPRODS, '', 'NONSSL')); $content = CONTENT_ALLPRODS; /* ------- file to be used for the content --------- */ require(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE); /* ------- template file to use ------------ */ require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> The 2nd part is the template file to be used. With the default install this is catalog/templates/main_page.tpl.php . Nothing needs to be done for this. The 3rd part is the file to be used for content. This file is placed in the catalog/templates/content/ directory and should be named the same as the application logic file except with a .tpl.php extention. This file is made by copying everything between: <!-- body_text //--> <td width="100%" valign="top"> and </td> <!-- body_text_eof //--> For allprods it would be named allprods.tpl.php and would look like this: <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE; ?></td> <td align="right"></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="2"> <?php $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order"); while ($languages = tep_db_fetch_array($languages_query)) { $languages_array[] = array('id' => $languages['languages_id'], 'name' => $languages['name'], 'code' => $languages['code'], 'image' => $languages['image'], 'directory' => $languages['directory']); } for ($i=0; $i<sizeof($languages_array); $i++) { $this_language_id = $languages_array[$i]['id']; $this_language_name = $languages_array[$i]['name']; $this_language_code = $languages_array[$i]['code']; $this_language_image = $languages_array[$i]['image']; $this_language_directory = $languages_array[$i]['directory']; echo " <tr>n"; $products_query = tep_db_query("SELECT p.products_id, pd.products_name FROM " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd WHERE p.products_id = pd.products_id AND p.products_status = 1 AND pd.language_id = $this_language_id ORDER BY pd.products_name"); $products_array = array(); while($products = tep_db_fetch_array($products_query)) { $products_array[] = array('id' => $products['products_id'], 'name' => $products['products_name']); } for ($j=0; $j<NR_COLUMNS; $j++) { echo " <td class=main valign="top">n"; for ($k=$j; $k<sizeof($products_array); $k+=NR_COLUMNS) { $this_products_id = $products_array[$k]['id']; $this_products_name = $products_array[$k]['name']; echo " <a href="" . tep_href_link(FILENAME_PRODUCT_INFO, 'name=' .str_replace("/", "/", rawurlencode($this_products_name)). '&products_id=' . $this_products_id . (($this_language_code == DEFAULT_LANGUAGE) ? '' : ('&language=' . $this_language_code)), 'NONSSL', false) . "">" . $this_products_name . "</a><br>n"; } echo " </td>n"; } echo " </tr>n"; } ?> </td> </tr> </table></td> </tr> <tr> <td align="right" class="main"><br><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL') . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td> </tr> </table> To finish the install of any new page the file names have to be defined. Open catalog/includes/filenames.php and add the following lines: define('CONTENT_ALLPRODS', 'allprods'); define('FILENAME_ALLPRODS', CONTENT_ALLPRODS . '.php'); Use the rest of the allprods installation documentation the same. Quote Perdure - Transparent Object Relational Persistence Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.