Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

STS - how do I make templates for each category?


ACE99

Recommended Posts

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

Link to comment
Share on other sites

Thanks Chris! Your suggestion works perfectly.

 

By the way, I was trying to figure out how to change the HEADER_TITLE on every category page so they are unique depending on the category. I'd also like to completely remove the HEADER_TITLE from the homepage. I tried just leaving the parameters for the line below in index.php blank, as follows:

 

define('HEADING_TITLE', '');

 

but that still leaves an awful space on my homepage where the title should be.

 

Any tips?

Link to comment
Share on other sites

Thanks Chris!  Your suggestion works perfectly. 

 

By the way, I was trying to figure out how to change the HEADER_TITLE on every category page so they are unique depending on the category.  I'd also like to completely remove the HEADER_TITLE from the homepage.  I tried just leaving the parameters for the line below in index.php blank, as follows:

 

define('HEADING_TITLE', '');

 

but that still leaves an awful space on my homepage where the title should be.

 

Any tips?

Greetings!

 

Great idea with the categories - I'll try to add something like this to the next version of STS.

 

As to adding Page Titles, I'd recommend using Linda's Header Tag Controller. It lets you customize the Title, Meta-tag fields on a per-item basis that makes it look better.

 

Also, you might want to keep future posts over on the main thread if you want me to see it (thanks Chris, for the cross-post).

 

- Brian

Simple Template System (STS)

Layout your site with 1 (or more) HTML file!

Download STS: http://www.oscommerce.com/community/contributions,1524

Support: http://www.oscommerce.com/forums/index.php?showtopic=58541

Link to comment
Share on other sites

The main support thread for the STS system can be found at http://www.oscommerce.com/forums/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://www.oscommerce.com/forums/index.php?sho...ndpost&p=303341

 

 

Cheers,

 

-C

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.

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...