Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[contribution] Simple Template System (sts)


DiamondSea

Recommended Posts

ISBEEN wrote:

 

having a hard time searching for this, but I've been putting up a few new osc sites, with 2.2ms2 v2 & the latest STS, and every time, each page has a trailing

 

</

 

Check to make sure you are running the latest version of PHP. I'm pretty sure it has to do with the version of PHP you gave. Check this thread and you will find several posts (and answers) relating to this problem.

Link to comment
Share on other sites

You can do just about anything you want with it and still have the basic OCS engine.?

By "do anything" do you mean, design a site and then apply the OSC engine behind it? Kind of like plugging in the OSC parts behind a frontend that's built separately?

 

That's what I need to do-- design an "artsy" site, then plug a database behind it. Is this what the STS contribution is capable of? I already know how to change colors of things using the stylesheet and html code.

 

Thanks for your input, Guy!

Daniel - Jenn,

 

Yes, you can design your page and then plug in the contents of the OSC engine that you want, breadtrails, header, footer, etc. STS comes with a templete that you can open in an html editor such as Front Page, Netscape, or just about any WYSIWYG editor and then you just change the contents. You can remove tables or add tables insert text images just about anything you want. At the moment I'm trying to get the htaccess file to funtion correctly and as soon as I do I'll point both of you to my site.

 

Daniel give it a try as I liked it better than BTS as it was much eaiser to use and understand. Now some of the other contributions leave a little to be desired and should never have been added to the contribution list as they just plain don't work. STS is one of those few contributions that does work.

Link to comment
Share on other sites

Yep, this won't work. I'll try to whip up a fix for you...

 

- bg

Thank you brian, I will watch this thread for an update, let me know how I can help!

 

-Daryl

Oak Creek Printworks Store

Link to comment
Share on other sites

So for example, a template for product with ID=17 would look like: "product_info.php_17.html".

 

*IDEA: Also if you have lots of products, and you want 1 template for say all your computer-related products which have ID's 1-20, you could change the code above a little and add an IF statement to check a range of ID's and then call a specific template for all those products.  I haven't done this myself and so I can't help you out on it, but it seems like it would be easy to do.

 

Anyway, this code works for me.  Hopefully it will work for you guys too!

 

-Philip

Great idea Philip and I would be interested to see if any of the coders here can see if this can be done with a simple code change, I am a designer and this would open much possible options for me and I think others.

 

Brian this is such a great contribution, and I look forward to the next update. :D

Link to comment
Share on other sites

Yeah, it would be nice to have templates for a range of products, or a specific type of product. What might be even better though is to have product-specific templates per category, so for example if you have a category of computer products, then you should be able to change that code I gave you so that it will check the category the product is in (cPath/x/products_id...), and call a template for the product pages that fall under this category. I'll see if I can figure this one out.

 

By the way, some people have said STS slows down your site. I don't think this is true, and if it does then the speed decrease is almost not noticeable.

 

If you have a slow site:

 

1. Decrease picture sizes on your pages and the content that loads.

2. In your store admin on the "configuration" page, change "Show Category Counts" to false. This makes a HUGE difference!

3. In admin, turn on the cache feature, and if you are on a shared server, make sure the directory is somthing like tmp/mysite, so your files don't get mixed up with someone else (I only say this b/c some people say it has happened.)

4. Turn on Gzip compression in the admin with a compression level of 1.

 

If all this doesn't speed up the store, then

 

5. Get a faster server. You get what you pay for. I was paying $20 a month and my store was slow as ever to access. Then I moved to PAIR networks and paid 3x more, but my site loads at lightning speed.

6. Install the "Faster Page Loads, Less DB Queries" contrinution, and the "DB Optimize" contribution.

7. still slow? You may have some other contribution or code that is messing with STS.

 

Anyway, hope that helps.

Link to comment
Share on other sites

How to get the credit card error messages to show up during checkout, when using AuthorizeNet Consolidated for AIM 1.7 contribution and STS.

 

Many have had problems with credit card error messages showing up during checkout when using the AIM 1.7 contribution, and maybe other payment modules too. This code fixes the problem:

 

 

Look for this in includes/sts_display_output.php

 

 // Prepend any error/warning messages to $content
 if ($messageStack->size('header') > 0) {
   $template['content'] = $messageStack->output('header') . $template['content'];
 }

 

Add this right after it.

 

////////Start Error Messages - Tom Wojcik
 if (isset($HTTP_GET_VARS['error_message']) && tep_not_null($HTTP_GET_VARS['error_message'])) {
$messageStack->add('error_message', $HTTP_GET_VARS['error_message']);
$template['content'] =  $messageStack->output('error_message') . $template['content'];
 }
////// End Error Messages

 

This was conributed by Tom. And for those looking to use AIM 1.7, or authorizeNet, it works just fine with STS.

 

-Philip

Link to comment
Share on other sites

allright i have a clean install of osc now when i go to upload all the files there is no /catalog/includes dir. when i read the readme it leads me to belive that it already exists and i overright the files in there. Is this correct or do i creat the dir?

 

steve

Link to comment
Share on other sites

well jenny,

 

i hav one up

 

guy,

 

well i'm not so sure bout sts, i tried making minor change like having the background changed to black color, but after saving & uploading the file, the page is still in normal white background

 

I moved the $login & $catalog to the top to have them on the right hand side of the logo. it worked but all the font & size changed. so how do i make them follow the settings in the stylesheet?

Edited by Johnson
Link to comment
Share on other sites

Danieln, just use the stylesheet.css to change the background of your site. It is at the top of the code just look for this code and change the background to #000000

 

or 'zeros' not "O"

 

BODY {

background: #EFEFFF;

color: #000000;

margin: 0px;

Link to comment
Share on other sites

how bout if i would like to have templates purchased & used for my site? u know those jpeg & gif files at the background to make my page more lifely?

 

wat faq page u meaning?

Link to comment
Share on other sites

HOW TO CREATE PRODUCT-SPECIFIC TEMPLATES IN STS:

 

*IDEA: Also if you have lots of products, and you want 1 template for say all your computer-related products which have ID's 1-20, you could change the code above a little and add an IF statement to check a range of ID's and then call a specific template for all those products.  I haven't done this myself and so I can't help you out on it, but it seems like it would be easy to do.

 

-Philip

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

Link to comment
Share on other sites

You could purchase templates and for that matter you can purchase whole sites ready to go with what you need. You have a very good site going now and all you need to do is add to it and you will have a very good looking site. Also, you can purchase clip art to add to the images displayed or use some of the clip art that is all ready in your computer. from what I saw of your site you have gone a long way in setting it up and have done a lot of work to get to where you are. Great Job!

Link to comment
Share on other sites

Actually quite well. I found the FAQ you are using and added it to my site. Just now starting to populate it and add the rest of the information areas.

 

Guy

Edited by Johnson
Link to comment
Share on other sites

interesting

 

hm....how bout removing the links in the information box if ur not using it? dat will make the site look more complete than having broken links

:)

Link to comment
Share on other sites

Haha! Yeah. I haven't gotten that far yet just been trying to get every thing else set up. This has been a month so far. If my regular job didn't take me out of town all the time I could do more with it but I usually only have the weekend to play with code. I'll probably populate those areas next weekend and should be ready to start advertlising soon after.

Link to comment
Share on other sites

i believe this has been asked b4, but just can't located it

 

i need to create new boxes. how to i go about it with sts? how's the naming & file structure that i need to follow?

 

thanks

Link to comment
Share on other sites

Hmmm, a new release. I wonder if it will fix the problems I have posted here and not gotten resolved.

 

1- I cannot make the "Click to Enlarge" feature work. Multiple posts in this thread, no solution as of yet...

 

2- I just checked to see if the rest of my website is at least functioning correctly. It was all functioning correctly before adding STS. But now, since I added a different login image on the home page to replace the one I had on my original site, it takes you to the wrong (original)login page. When you click on the new snazzy image, you are taken to the old login page. I have no clue how to tell it to get to the correct login page. Perhaps this broke an earlier contribution? Who knows, I certainly don't.

 

As far as I am concerned, my website now looks great, but it is broken in multiple places. STS is leaving a bad taste in my mouth.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...