Jump to content

Jaxx

Members
  • Content count

    28
  • Joined

  • Last visited

Everything posted by Jaxx

  1. Another method for product specific templates In order to use the same template for a group of related files (using IF statements in ranges would get unwieldy in a hurry since there is no guarantee that related products would have sequential product ids in the table) you could either: 1. Create the product template, then copy/rename the template for each file; 2. Create the product template, then assign that template file for each product that uses it. Option 2 would be more elegant, since it eliminates duplicate files for each product sharing the template. Also, you only have to edit a single file to modify the template, which is really the point to any template system. Here is a step by step procedure to implement this technique. 1. Use following SQL query to add template filename field to products_description table ALTER TABLE `products_description` ADD `products_sts_templ_filename` VARCHAR( 30 ); 2. In product_info.php, change line 84 from: $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); to: $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, pd.products_sts_templ_filename from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); 3. In sts_display_output.php, use the modified product template code below instead of the original code (this is to be placed at around line 113, directly after the category template check): // Are we in the product_info.php script? if ($scriptbasename == "product_info.php") { // Look to see whether the product id was sent, otherwise don't bother if (isset($HTTP_GET_VARS['products_id'])) { $sts_productid = $HTTP_GET_VARS['products_id']; // If a template was assigned in table products_description, use it if (tep_not_null($product_info['products_sts_templ_filename'])) { $sts_check_file = STS_TEMPLATE_DIR . $product_info['products_sts_templ_filename']; if (file_exists($sts_check_file)) { // Use it $sts_template_file = $sts_check_file; } } // Look for product-specific template file like "product_info.php_17.html" // Note that this will override any value entered in products_sts_templ_filename $sts_check_file = STS_TEMPLATE_DIR . "product_info.php_$sts_productid.html"; if (file_exists($sts_check_file)) { // Use it $sts_template_file = $sts_check_file; } } } At this point, the system is functional. Any filename assigned to a product in the database will be used as the product template (remember to put the file in catalog/includes/sts_templates); defining a specific template filename such as product_info.php_17.html will override the database value. If no product specific template exists, the default template is used. That was the easy part. But right now you'd need to use a tool like phpMyAdmin to edit the table and add template filenames to the product_descriptions table. To make things easier we'll make the field editable from the osc admin tool. 4. Make the following changes to /admin/categories.php: 4a. Around line 249, add the following line to the $sql_data_array = array(... statement: 'products_sts_templ_filename' => tep_db_prepare_input($HTTP_POST_VARS['products_sts_templ_filename'][$language_id]), NOTE: It's best to add this somewhere in the middle of the array elements, like second from the bottom or something. DO NOT MAKE THIS STATEMENT THE LAST ELEMENT IN THE LIST -- YOU'LL HAVE TO CHANGE THE LIST PUNCTUATION IF YOU DO. 4b. Around line 305, add 'products_sts_templ_filename, ' (without the quotes) to $description_query line after 'products_description, '. 4c. Around line 307, add 'products_sts_templ_filename, ' (without the quotes) to tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION... line after 'products_description, '. 4d. Around line 380, after the if ($action == 'new_product') { line, replace the $parameters = array(... statement with the following: $parameters = array('products_name' => '', 'products_description' => '', 'products_url' => '', 'products_id' => '', 'products_quantity' => '', 'products_model' => '', 'products_image' => '', 'products_price' => '', 'products_weight' => '', 'products_date_added' => '', 'products_last_modified' => '', 'products_date_available' => '', 'products_status' => '', 'products_tax_class_id' => '', 'manufacturers_id' => '', 'products_sts_templ_filename' => ''); 4e. Around line 404, after the if (isset ($HTTP_GET_VARS['pID']) && (!$HTTP_POST_VARS) ) { line, replace the $product_query =... with the following: $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, pd.products_sts_templ_filename, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); 4f. Around line 408, change the } elseif (tep_not_null($HTTP_POST_VARS)) { statement to the following: } elseif (tep_not_null($HTTP_POST_VARS)) { $pInfo->objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_url = $HTTP_POST_VARS['products_url']; $products_sts_templ_filename = $HTTP_POST_VARS['products_sts_templ_filename']; } 4g. Around line 672, add the following code just above the closing </table> tag (right below the PRODUCTS_WEIGHT rows): <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td> </tr> <?php for ($i=0, $n=sizeof($languages); $i<$n; $i++) { ?> <tr> <td class="main" valign="top"><?php if ($i == 0) echo TEXT_PRODUCTS_STS_FILENAME; ?></td> <td><table border="0" cellspacing="0" cellpadding="0"> <tr> <td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?> </td> <td class="main"><?php echo tep_draw_input_field('products_sts_templ_filename[' . $languages[$i]['id'] . ']', (isset($products_sts_templ_filename[$languages[$i]['id']]) ? $products_sts_templ_filename[$languages[$i]['id']] : $pInfo->products_sts_templ_filename)); ?></td> </tr></table> </tr> <?php } ?> 4h. Around line 695, change the <?php ... ?> block to the following: <?php } elseif ($action == 'new_product_preview') { if (tep_not_null($HTTP_POST_VARS)) { $pInfo = new objectInfo($HTTP_POST_VARS); $products_name = $HTTP_POST_VARS['products_name']; $products_description = $HTTP_POST_VARS['products_description']; $products_head_title_tag = $HTTP_POST_VARS['products_head_title_tag']; $products_head_desc_tag = $HTTP_POST_VARS['products_head_desc_tag']; $products_head_keywords_tag = $HTTP_POST_VARS['products_head_keywords_tag']; $products_url = $HTTP_POST_VARS['products_url']; $products_sts_templ_filename = $HTTP_POST_VARS['products_sts_templ_filename']; } else { $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, pd.products_sts_templ_filename, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . $HTTP_GET_VARS['pID'] . "'"); $product = tep_db_fetch_array($product_query); } $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; echo tep_draw_form($form_action, FILENAME_CATEGORIES, 'cPath=' . $cPath . (isset($HTTP_GET_VARS['pID']) ? '&pID=' . $HTTP_GET_VARS['pID'] : '') . '&action=' . $form_action, 'post', 'enctype="multipart/form-data"'); $languages = tep_get_languages(); for ($i=0, $n=sizeof($languages); $i<$n; $i++) { if (isset($HTTP_GET_VARS['read']) && ($HTTP_GET_VARS['read'] == 'only')) { $pInfo->products_name = tep_get_products_name($pInfo->products_id, $languages[$i]['id']); $pInfo->products_description = tep_get_products_description($pInfo->products_id, $languages[$i]['id']); $pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]); $pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]); $pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]); $pInfo->products_url = tep_get_products_url($pInfo->products_id, $languages[$i]['id']); $pInfo->products_sts_templ_filename = tep_db_prepare_input($products_sts_templ_filename[$languages[$i]['id']]); } else { $pInfo->products_name = tep_db_prepare_input($products_name[$languages[$i]['id']]); $pInfo->products_description = tep_db_prepare_input($products_description[$languages[$i]['id']]); $pInfo->products_head_title_tag = tep_db_prepare_input($products_head_title_tag[$languages[$i]['id']]); $pInfo->products_head_desc_tag = tep_db_prepare_input($products_head_desc_tag[$languages[$i]['id']]); $pInfo->products_head_keywords_tag = tep_db_prepare_input($products_head_keywords_tag[$languages[$i]['id']]); $pInfo->products_url = tep_db_prepare_input($products_url[$languages[$i]['id']]); $pInfo->products_sts_templ_filename = tep_db_prepare_input($products_sts_templ_filename[$languages[$i]['id']]); } ?> 4i. Around line 825, add the following line to the list of hidden fields: echo tep_draw_hidden_field('products_sts_templ_filename[' . $languages[$i]['id'] . ']', htmlspecialchars(stripslashes($products_sts_templ_filename[$languages[$i]['id']]))); 5. Add the following lines to /catalog/admin/includes/languages/<insert_your_language(s)_here>/categories.php: // STS Product Template Field define('TEXT_PRODUCTS_STS_FILENAME', 'STS Template Filename:'); One of the interesting side effects of putting the code in the product_description table is that to get it to work properly it had to support multiple languages, so there's the added feature of having product-specific templates on a per-language basis for you multilingual users out there. This started out as a pretty simple mod - til I got to the admin panel. I don't think that I'll try to figure out the OSC admin interface overnight anymore. ;) If step 4 is too confusing, I'll post my categories.php in its entirety and you can do a diff on it for the changes. The big thing to check for are the references to products_sts_templ_filename in the code. Cheers, Chris
  2. Forgot to mention that you can also directly assign template variables by simply using $template['variablename'] = "Your Content Here"; for whatever you want placed in that space. My bad for omitting this. -C
  3. Check out the following posts in this thread: http://forums.oscommerce.com/index.php?sho...ndpost&p=232735 http://forums.oscommerce.com/index.php?sho...ndpost&p=308077 http://forums.oscommerce.com/index.php?sho...ndpost&p=306849 You define custom boxes in sts_user_code.php. The readme file has more detailed info in it, but you essentially turn the capture on, call the code you want to capture, give it a variable name, turn off the capture and parse the variable. The variables are set in sts_display_output.php and in sts_user_code.php. It's possible to use the capture code framework used in sts_user_code.php elsewhere, as long as you're mindful of the capture flow described in the other post and change as needed. You can't add code to the template and change the extension to php and have it work because the template is never executed in the code - it's just loaded into a string variable and the variables are merged into it in sts_display_output.php. -C
  4. Ray: To get STS to capture a block to redisplay on the template you assign the variable $sts_block_name to a name, and then turn on the capture buffer using calls to STS_START_CAPTURE. Once the output you want in the block has executed, use STS_STOP_CAPTURE to stop the buffering, or STS_RESTART_CAPTURE to stop buffering and restart a new capture block. As long as $sts_block_name is set before you stop or restart the capture buffer, things are ok. So the code basically looks like this (taken from sts_user_code.php): $sts_block_name = 'newcontent'; require(STS_START_CAPTURE); // stuff you want to display goes here require(STS_STOP_CAPTURE); $template['newcontent'] = strip_unwanted_tags($sts_block['newcontent'], 'newcontent'); Mibble: Inside sts_display_output.php is code to call the Header Tag Controller code if it's detected. Because the header tags are called and captured in sts_display_output you don't have to do all the modifications to all of the files to add the header tag support. However, because it's called in sts_display_output, if you add the header tag code to application_top per the instructions in HTC you get the redeclaration error caused by clean_html_comments (part of HTC) getting called twice. The solution is to only add the call to clean_html_comments in application_top and just delete out the call to clean_html_comments from inside sts_display_output.php. See the post I made a few pages back about it for more detail, where I posted changes to be made regarding making STS, HTC and Article Manager to make nice. -C
  5. I haven't used Smarty, but I was checking out the site and it looks interesting. The caching could be useful. But then, I'd probably stay at rev 2.01 for now. I just got used to it and now you want to change the codebase on me. ;) -C
  6. lostinosc: First, I assume that you tested and confirmed the fresh install of osC MS2 was working properly before installing STS. It appears that the configuration to get STS installed was not completed properly. I would check to make sure the defines in catalog/includes/configure.php are correct. line in sts_display_output.php should read: // Start with the default template $sts_template_file = STS_DEFAULT_TEMPLATE; lines in configure.php should read: define('STS_START_CAPTURE', DIR_WS_INCLUDES . 'sts_start_capture.php'); define('STS_STOP_CAPTURE', DIR_WS_INCLUDES . 'sts_stop_capture.php'); define('STS_RESTART_CAPTURE', DIR_WS_INCLUDES . 'sts_restart_capture.php'); define('STS_TEMPLATE_DIR', DIR_WS_INCLUDES . 'sts_templates/'); define('STS_DEFAULT_TEMPLATE', DIR_WS_INCLUDES . 'sts_template.html'); define('STS_DISPLAY_OUTPUT', DIR_WS_INCLUDES . 'sts_display_output.php'); define('STS_USER_CODE', DIR_WS_INCLUDES . 'sts_user_code.php'); define('STS_PRODUCT_INFO', DIR_WS_INCLUDES . 'sts_product_info.php'); Based on the error messages you're receiving it appears that $sts_template_file is getting set to 'STS_DEFAULT_TEMPLATE', literally. Same with the call to STS_USER_CODE. Both of these should be constants defined in configure.php to a different value as above. HTH, -C
  7. The php output functions only buffer the script's output. The java applet is a separate program outside the script and therefore outside its scope. Check out the following link for more information: http://us2.php.net/manual/en/ref.outcontrol.php -C
  8. Hi Ray, This post by Brian describes the nutshell of how STS works: http://forums.oscommerce.com/index.php?sho...ndpost&p=232735 If you look closely at sts_display_output.php it defines a block called $headertags in which it either calls the Header Tags Controller mod if present or uses the stock TITLE define from english.php. It then strips the actual title content from the $headertags variable. So the header stuff that exists on all the other pages is ignored, which is what you would want to do if you're templating - you want that head information to come from your template file. Now, because all of the content on the page is being captured to a buffer and assigned to a string variable, any non-text or other code on the page being captured will get missed, which is why the java applet you have on the categories page isn't showing up with the template installed. Using the &sts_normal or setting the $display_normal_output to 1 should display the page without the template, allowing you to confirm this. One thing to keep in mind when using the STS is to note where the $sts_block_names get assigned. In general: $applicationtop2header: application_top.php to header.php $header: header.php $header2columnleft: header.php to column_left.php standard info boxes (see docs for detail): column_left.php, column_right.php $columnleft2columnright: column_left.php to column_right.php $columnright2footer: column_right to footer.php $counter: footer.php $footer: footer.php $banner: footer.php $footer2applicationbottom: footer.php to application_bottom.php user defined boxes: sts_user_code.php $catmenu: sts_user_code.php The reason this is important is because the capture starts with a call to STS_START_CAPTURE, then for each block through $banner STS_RESTART_CAPTURE is used instead, to continally capture output, and finally a STS_STOP_CAPTURE is used at $footer2applicationbottom. in sts_user_code.php each user defined block uses STS_START_CAPTURE and STS_END_CAPTURE on each block. If code gets placed without considering where the blocks are being captured (such as trying to put the Header Tags controller code in application_top AFTER the STS_START_CAPTURE) the output may not behave as you expected it to. HTH, -C
  9. If you look at the "view source" option in your browser you should see the tags you entered. It should be headed with <!-- BOF: Generated Meta Tags -->. -C
  10. Olorin, catalog/includes/languages/english/header_tags.php is the file you're looking for. It has all the default titles and tags for the site there. If you use other languages, simply copy the file to the appropriate language directory and make the appropriate changes. As you enter/edit products in the admin screen you'll see the area to enter in titles, descriptions and keywords for each specific product. There's also additional information on general use in the README to Operate.txt file that comes with version 2.2 that may help as well. HTH, -C
  11. If you're having difficulty getting the Header Tags Controller contrib to work with Simple Template System 1.9 and higher and Article Manager 1.2, check out the following post: http://forums.oscommerce.com/index.php?sho...ndpost&p=306163 To just get HTC and STS to work together you should be just fine with commenting out or deleting the HTC code in application_top.php. Some mods, however, expect clean_html_comments.php to be called in application_top. In those cases you can simply leave in the require call to clean_html_comments.php in application_top and change the require('clean_html_comments.php') to require_once('clean_html_comments.php') in sts_display_output.php It's seemed to have resolved the issues that I had with HTC and other contribs. -C
  12. Sorry. That should be Article Manager 1.2 - I was originally on STS 1.9, upgraded to 2.1 where everything is currently working. To get Header Tags Controller to work with STS you should simply not put in the HTC code into application_top.php, but this might cause issues elsewhere, as it did with Article Manager, which has a customization that affects HTC. See the post I referenced for details. -C
  13. If you're trying to get STS, Header Tags Controller and Article Manager 1.9 to work together, check out this post on how I got them to work: http://forums.oscommerce.com/index.php?sho...ndpost&p=306163 -C
  14. Jaxx

    Article Manager v1.0

    I found that Article Manager was not working with Simple Template System 1.9 and higher with the Header Tags Controller installed. To get the HTC and STS to work I stated in a previous post that all that was needed was to disable the HTC code in /catalog/includes/application_top.php, since STS has HTC support built already. Here's what I actually did to make everything play well together: /includes/application_top.php AM specifies to comment out the following line if HTC installed: require(DIR_WS_FUNCTIONS . 'clean_html_comments.php'); Line is left intact. HTC adds the following code: // BOF: WebMakers.com Added: Header Tags Controller v1.0 require(DIR_WS_FUNCTIONS . 'header_tags.php'); // Clean out HTML comments from ALT tags etc. require(DIR_WS_FUNCTIONS . 'clean_html_comments.php'); // Also used by: WebMakers.com Added: FREE-CALL FOR PRICE // EOF: WebMakers.com Added: Header Tags Controller v1.0 Comment out or delete this section. STS has support for HTC in sts_display_output.php. /catalog/includes/article_header_tags.php Added the following line to the end of the file, before the closing ?> tag: // flag to determine whether to use custom tags or article header tags with STS $use_ah_tags = 'true'; /catalog/article*.php Comment out or delete the HTC <?php ?> code blocks immediately above and below the <title><?php echo TITLE ?></title> line. Changed the code between <!-- header //--> and <!-- header_eof //--> to the following: <!-- header //--> <?php require(DIR_WS_INCLUDES . 'header.php'); // Moved header tag call to here to facilitate STS blocks if ( file_exists(DIR_WS_INCLUDES . 'article_header_tags.php') ) { require(DIR_WS_INCLUDES . 'article_header_tags.php'); } ?> <!-- header_eof //--> /includes/sts_display_output.php Lines 149-167 (stock file) are HTC support code. Changed the code to the following: // STS: ADD: Support for WebMakers.com's Header Tag Controller contribution // BOF: WebMakers.com Changed: Header Tag Controller v1.0 // Replaced by header_tags.php // Modified to work with Article Manager (which uses custom headers) if ($use_ah_tags == 'true') { // require(DIR_WS_INCLUDES . 'article_header_tags.php'); // don't process HTC - use headertags from article_header_tags } else { // Capture the output require(STS_START_CAPTURE); if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require_once(DIR_WS_FUNCTIONS . 'clean_html_comments.php'); require_once(DIR_WS_FUNCTIONS . 'header_tags.php'); require(DIR_WS_INCLUDES . 'header_tags.php'); } else { echo "<title>" . TITLE . "</title>"; } $sts_block_name = 'headertags'; require(STS_STOP_CAPTURE); } // EOF: WebMakers.com Changed: Header Tag Controller v1.0 // STS: EOADD: Support for WebMakers.com's Header Tag Controller contribution -C
  15. Jaxx

    Header Tag Controller

    P.S. Forgive the cross-post. Next time I'll simply include a reference to the main thread and reply there. -C.
  16. (crossposted from http://forums.oscommerce.com/index.php?showtopic=77299 - but I see Alysehia beat me to it ;) ) They do play well together. STS 1.9 has support for the Header Tag mod built into sts_display_output.php, so when you install the newest version of HTC make sure you don't add the code that's supposed to go into application_top.php. So far everything seems fine on my system. -C.
  17. Jaxx

    Header Tag Controller

    (crossposted to main STS thread at http://forums.oscommerce.com/index.php?showtopic=58541) They do play well together. STS 1.9 has support for the Header Tag mod built into sts_display_output.php, so when you install the newest version of HTC make sure you don't add the code that's supposed to go into application_top.php. So far everything seems fine on my system. -C.
  18. Jaxx

    Simple Template System (STS)

    The Main STS Support thread can be found here: http://forums.oscommerce.com/index.php?showtopic=58541 -C.
  19. Jaxx

    New infobox in STS???

    Hi Artur, The main thread for the STS can be found at the link below. You should be able to find the answers to your questions there. Simple Template System (STS) Cheers, -C
  20. The main support thread for the STS system can be found at http://forums.oscommerce.com/index.php?showtopic=58541 in case you haven't found it already. I responded to your HEADER_TITLE question over at the main thread so everyone could benefit, although it doesn't deal with STS directly. The post can be found here: http://forums.oscommerce.com/index.php?sho...ndpost&p=303341 Cheers, -C
  21. The Header Tag Controller is a great mod from what I've seen - I haven't integrated it yet - but it won't do anything on the HEADER_TITLE to make each category header (which isn't part of the actual HTML header) unique. There are several ways to do this. If have very few categories, a quick and really dirty solution could be to use conditional statements to set the define in the language's index.php. Obviously this hack would be impractical for more than a handful of categories, and it's ugly to boot. A better way to go about it would be to set HEADER_TITLE to another value, such as the category name, which is in the categories_description table. Here's how: Replace the references to HEADER_TITLE to $header_title in the 'nested' and 'products' IF blocks (the first two HEADER_TITLE occurrences of three total) in /catalog/index.php. It should look like <td class="pageHeading"><?php echo $heading_title; // echo HEADING_TITLE; ?></td> and <td class="pageHeading"><?php echo $heading_title; // echo HEADING_TITLE; ?></td> (I left the HEADING_TITLE tag commented out so I'd remember the edit.) Next, under the following code: if ($category_depth == 'nested') { $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'"); $category = tep_db_fetch_array($category_query); Add the lines: // added to display category-specific headings instead of HEADING_TITLE // references to HEADING_TITLE changed to $heading_title except in default page display $heading_title = $category['categories_name']; That takes care of the header name for the nested category display. For the category products display add the lines: // added to look up category name and use as table header instead of HEADING_TITLE if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) { $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and language_id = '" . (int)$languages_id . "'"); } else { $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$current_category_id . "' and language_id = '" . (int)$languages_id . "'"); } $category = tep_db_fetch_array($category_query); $heading_title = $category['categories_name']; This should be added just ABOVE the section that begins with // show the products of a specified manufacturer You should now be seeing the current category name as the header for the page table instead of the "Let's See what We Have Here" and whatnot. I opted to leave the HEADER_TITLE in for the default index view since that needs no customization beyond editing the original default define in the language index.php. This can be easily extended by adding an additional field to the categories_description table, such as header_title. You would then just change the query in $category_query to lookup new field name. If I went this far I'd modify the admin section to include the new field so I could edit the value easily. Cheers, -C
  22. Jaxx

    Article Manager v1.0

    Link to minor extension of Article Manager to use Mazza's latest article starter code in earlier posts. All code props go to him. Link to thread posted here for benefit of this thread (and relative continuity). Looking for News-Contrib in the middle of mainpage, What contrib should I take ? -C
  23. Hi Andreas! What you want to do is similar to article and content management that I've been looking at. I decided to go with Article Manager 1.2, which allows you to manage articles and topics from within the Admin area, and uses a WSIWYG editor to post articles and images. It's a nice mod. You can download Article Manager from here: http://www.oscommerce.com/community/contri...ons,1709/page,3 The main support thread for this contribution can be found here: http://forums.oscommerce.com/index.php?act=ST&f=7&t=68866 The installation instructions are pretty decent and straightforward. For what you (and I) want to do - add a box with latest articles - take a look at this post from the main Article Manager thread: http://forums.oscommerce.com/index.php?sho...ndpost&p=291439 Copy and paste the code into a new file in the catalog/modules directory. I called it articles_latest.php to keep the naming to conform with the rest of the mod. I then went to catalog/includes/languages/english.php file and added the following defines: define('MAX_NEW_ARTICLES_PER_PAGE', '5'); define('TEXT_NEW_ARTICLES', 'Latest Articles'); To view the box, simply use an include statement wherever you want the box to appear as follows: <?php include(DIR_WS_MODULES . 'articles_latest.php'); ?> For example, you could put the above statement in index.php in place of the new product listing, or above it, below it, in other modules, etc. The contents of the box can be easily modified to return articles from a single topic just by modifying the query in articles_latest.php from $articles_new_query_raw = "select a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_head_desc_tag, au.authors_id, au.authors_name, td.topics_id, td.topics_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t left join " . TABLE_TOPICS_DESCRIPTION . " td on a2t.topics_id = td.topics_id left join " . TABLE_AUTHORS . " au on a.authors_id = au.authors_id, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = a2t.articles_id and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' order by a.articles_date_added desc, ad.articles_name"; to $articles_new_query_raw = "select a.articles_id, a.articles_date_added, ad.articles_name, ad.articles_head_desc_tag, au.authors_id, au.authors_name, td.topics_id, td.topics_name from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t left join " . TABLE_TOPICS_DESCRIPTION . " td on a2t.topics_id = td.topics_id left join " . TABLE_AUTHORS . " au on a.authors_id = au.authors_id, " . TABLE_ARTICLES_DESCRIPTION . " ad where a.articles_id = a2t.articles_id and a.articles_status = '1' and a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' and td.topics_id = [B]#[/B] order by a.articles_date_added desc, ad.articles_name"; where # should be the id# of the desired topic. Tweak the table formatting a little bit, and you're done. Cheers, -C
  24. This is from the thread STS - how do I make templates for each category? - I'm posting my response here for the benefit of the main support thread. Thanks Brian for the great contrib - this is what I had in mind for a templating system. Cheers, -C
  25. I've been studying the code for the stock MS2 and STS 1.9 and just happened to be looking at the portions in question. One quick and simple possibility would be to set $sts_template_file to the appropriate template file based on $current_category_id using a CASE block, if statements, etc. This check could ideally be integrated into the script check at line 80 in sts_display_output.php, or placed just below it. Example (code block begins at line 78 in sts_display_output.php): // See if there is a template file for the currently running script $sts_template_file = STS_TEMPLATE_DIR . $scriptbasename . ".html"; if (file_exists($sts_template_file)) { // Use it } else { // This assumes the category template is named after the category id $sts_template_file = STS_TEMPLATE_DIR . $current_category_id . ".html"; if (file_exists($sts_template_file)) { // Use the category template } else { // Otherwise, use the default template $sts_template_file = STS_DEFAULT_TEMPLATE; } } In that example the category template name is based on the category id. So using the default data, the template for Hardware (ID=1) would be named 1.html. You can reference the categories_description table for the category descriptions and names. Keep in mind that this is just a "quick and dirty" solution that can be extended from this point. Cheers, -C
×