ACE99 Posted February 3, 2004 Share Posted February 3, 2004 STS v1.9 - How can I create template pages for every category page, so that the web site will look different depending on the category that the user is browsing? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 3, 2004 Share Posted February 3, 2004 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 Quote Link to comment Share on other sites More sharing options...
ACE99 Posted February 3, 2004 Author Share Posted February 3, 2004 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? Quote Link to comment Share on other sites More sharing options...
DiamondSea Posted February 4, 2004 Share Posted February 4, 2004 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 Quote 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 More sharing options...
Guest Posted February 4, 2004 Share Posted February 4, 2004 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 Quote 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.