{"id":496,"date":"2011-06-25T11:05:21","date_gmt":"2011-06-25T01:05:21","guid":{"rendered":"http:\/\/howden.net.au\/thowden\/?p=496"},"modified":"2011-06-25T11:05:21","modified_gmt":"2011-06-25T01:05:21","slug":"oscmax-template-main-page-different-from-rest-of-site","status":"publish","type":"post","link":"https:\/\/howden.net.au\/thowden\/2011\/06\/oscmax-template-main-page-different-from-rest-of-site\/","title":{"rendered":"osCmax Template main page different from rest of site"},"content":{"rendered":"<p>Depending on which posts you read in the osCmax forums you get a different lot of questions around handling having a different main or index page from the rest of the site.<\/p>\n<p>The <a title=\"Managing templates in osCmax\" href=\"http:\/\/www.oscmax.com\/forums\/oscmax-v2-features-discussion\/14626-bts-template-tutorial-examples-converting-oscommerce-template-bts.html\" target=\"_blank\">forum article on BTS templates<\/a> has what I needed to make these changes, but it&#8217;s buried down the page. Open the forum article and search in the page for &#8216;main2&#8217; and you&#8217;ll find the relevant information. So why write this up? Because I find some of the instructions ambiguous.<\/p>\n<p>In the catalog or \/ directory of the osCmax site each of\u00a0the .php files that controls a page includes a control link to the main_page.tpl.php<\/p>\n<p>[php]include (bts_select(&#8216;main&#8217;)); \/\/ BTSv1.5<br \/>\n[\/php]<\/p>\n<p>is found in the code (generally near the end of the file) and the activity \/ actions of the file push the results off to the template for display.<\/p>\n<p>In this case I want to modify the \/index.php file \u00a0and rather than using main2, I&#8217;ll name it as main_index.<\/p>\n<p>Open the \/index.php and at the very end of the file around line 335 is<\/p>\n<blockquote><p>include (bts_select(&#8216;main&#8217;)); \/\/ BTSv1.5<\/p><\/blockquote>\n<p>Change this to<\/p>\n<blockquote><p>include (bts_select(&#8216;main_index&#8217;)); \/\/ BTSv1.5<\/p><\/blockquote>\n<p>Close index.php as this is finished with.<\/p>\n<p>Open \/includes\/configure_bts.php at line 19 copy the existing line<\/p>\n<blockquote><p>define(&#8216;TEMPLATENAME_MAIN_PAGE&#8217;, &#8216;main_page.tpl.php&#8217;);<\/p><\/blockquote>\n<p>and paste it again and edit as the second line for the new page template<\/p>\n<blockquote><p>define(&#8216;TEMPLATENAME_MAIN_PAGE&#8217;, &#8216;main_page.tpl.php&#8217;);<br \/>\ndefine(&#8216;TEMPLATENAME_MAIN_INDEX_PAGE&#8217;, &#8216;main_index_page.tpl.php&#8217;);<\/p><\/blockquote>\n<p>Then find at around line 43<\/p>\n<blockquote><p>case &#8216;main&#8217;:<br \/>\n\/\/ default or main_page<br \/>\nif(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE)) {<br \/>\n$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE);<br \/>\n} else {<br \/>\n$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_PAGE);<br \/>\n}<br \/>\nbreak;<\/p><\/blockquote>\n<p>and copy and paste this as a second block immediately below the first and edit it as shown<\/p>\n<blockquote><p>case &#8216;main&#8217;:<br \/>\n\/\/ default or main_page<br \/>\nif(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE)) {<br \/>\n$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_PAGE);<br \/>\n} else {<br \/>\n$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_PAGE);<br \/>\n}<br \/>\nbreak;<\/p>\n<p>case &#8216;main_index&#8217;:<br \/>\n\/\/ default or main_page<br \/>\nif(is_file(DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_INDEX_PAGE)) {<br \/>\n$path = (DIR_WS_TEMPLATES . TEMPLATENAME_MAIN_INDEX_PAGE);<br \/>\n} else {<br \/>\n$path = (DIR_WS_TEMPLATES_FALLBACK . TEMPLATENAME_MAIN_INDEX_PAGE);<br \/>\n}<br \/>\nbreak;<\/p><\/blockquote>\n<p>Close the configure_bts.php file as this is finished with.<\/p>\n<p>Next in the template directory that you are using (<a href=\"\/2011\/06\/oscmax-templates\/\">I cover that bit elsewhere<\/a>) copy the<\/p>\n<blockquote><p>main_page.tpl.php<br \/>\nmain_page.html<br \/>\nmain_page.code.php<\/p><\/blockquote>\n<p>as new files:<\/p>\n<blockquote><p>main_index_page.tpl.php<br \/>\nmain_index_page.html<br \/>\nmain_index_page.code.php<\/p><\/blockquote>\n<p>If you use a text editor like EditPlus then opening the files and using Save As is another option.<\/p>\n<p>The final step is to edit the main_index_page.tpl.php file<\/p>\n<p>There are two lines that reference the other files:<br \/>\nLine 33:<\/p>\n<blockquote><p>function bts_read_php($php_template = &#8216;main_page.code.php&#8217;) {<\/p><\/blockquote>\n<p>change to<\/p>\n<blockquote><p>function bts_read_php($php_template = &#8216;main_index_page.code.php&#8217;) {<\/p><\/blockquote>\n<p>and line 52:<\/p>\n<blockquote><p>function bts_read_html($php_code_array, $html_template = &#8216;main_page.html&#8217;) {<\/p><\/blockquote>\n<p>change to<\/p>\n<blockquote><p>function bts_read_html($php_code_array, $html_template = &#8216;main_index_page.html&#8217;) {<\/p><\/blockquote>\n<p>Close this file as it is ready.<\/p>\n<p>Make some changes in the main_index.html page so that you can see a difference and test your new template main page and another page to see that you have it all working. Once this is done, editing the two separate file pairs of .html and .code.php will allow for the setup of two types of layouts.<\/p>\n<p>Of course, this can then be applied for a third or many multiples of layouts within the same site or template.<\/p>\n<p>Now, this is the suggested process gleaned from various forum posts. I think there is a better way as I&#8217;d prefer to minimise the modifying of the core application files and this breaks the template switching process.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Depending on which posts you read in the osCmax forums you get a different lot of questions around handling having a different main or index page from the rest of the site. The forum article on BTS templates has what I needed to make these changes, but it&#8217;s buried down the page. Open the forum [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-496","post","type-post","status-publish","format-standard","hentry","category-oscommerce-oscmax"],"_links":{"self":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts\/496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/comments?post=496"}],"version-history":[{"count":0,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/posts\/496\/revisions"}],"wp:attachment":[{"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/media?parent=496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/categories?post=496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howden.net.au\/thowden\/wp-json\/wp\/v2\/tags?post=496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}