Author Topic: Custom Home Page with it's own set of infobox options and stylesheet?  (Read 3803 times)

0 Members and 1 Guest are viewing this topic.

David M. Graham

  • Administrator
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 380
  • Karma: 12
    • View Profile
    • osCommerce University
Re: Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #6 on: October 26, 2008, 06:17:48 PM »
Sorry I missed this post!

No, the trick is to use an if statement to change which main page template is required.

Add:

define('TEMPLATENAME_ALTERNATE_MAIN_PAGE','main_page2.tpl.php');

to the template.php file.

Then in index.php (root file in the catalog dir, aka front end controller)

use:

if ($content && CONTENT_INDEX_DEFAULT) {

  require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_ALTERNATE_MAIN_PAGE);
}else{
  require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);
}

instead of just:

  require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);



for example, should do it.  (consider this pseudocode, you may need to tweak, but the logic is right.

Liquid

  • Newbie
  • *
  • Offline Offline
  • Posts: 14
  • Karma: 2
    • View Profile
Re: Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #5 on: October 10, 2008, 04:43:49 AM »
When I get this right, I will be pulling my hacked code out of features.php which checks the URL/pagename of the current page that's loaded to determine if it's the home page or any other. I had an "if-else" in features.php. Inappropriate location for logic, but it does work :P

I haven't successfully implemented your technique yet, this non-functional example doesn't use an if statement, instead placing a hardcoded home page layout inside the else which determined the CONTENT_INDEX_DEFAULT.

Original code from index.php:
Code: [Select]
  } else { // default page

    $content = CONTENT_INDEX_DEFAULT;

  }

Changed to:
Code: [Select]
  } else { // default page

    $content = CONTENT_INDEX_DEFAULT;
// t added to hardcode alternate home page layout which can have it's own stylsheet, layout but will also need hardcode box inclusions
define('TEMPLATENAME_MAIN_PAGE', 'myhome_page.tpl.php'); 
  }

This failing to work, I then tried placing the define('TEMPLATENAME_MAIN_PAGE', 'myhome_page.tpl.php') inside an if statement you suggested, at the bottom of the file, but haven't got it right yet.

David M. Graham

  • Administrator
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 380
  • Karma: 12
    • View Profile
    • osCommerce University
Re: Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #4 on: October 08, 2008, 10:50:09 PM »
I'm working on some code to determine if the home page is being served, right now it's inside main_page.tpl.php, then I would do an if-else inside that file to paint a standard template or a special one for a home page.

If I could create an alternate index_page.tpl.php and link that into filenames.php, that'd be great, but it doesn't look like I should be putting code into filenames.php, since it's just defines.

Thanks David for responding with a technique for a clean way to do this.
"Then modify the index files to use it instead for the home page."

My question is:
What are the "index files" that I can modify to substitute the index_page.tpl.php to run only when it's the home page?

The "index" pages share a single root file or "front end controller".  That would be the catalog/index.php file.  It uses several definitions to set which index template is used, but calls main_page.tpl.php for all of them.

You would need to determine whether you considered CONTENT_INDEX_PRODUCTS, CONTENT_INDEX_DEFAULT, CONTENT_INDEX_NESTED or a combination of them to be the home page.  Then, for each that you considered to be a "home page" layout, call the alternate page layout.

I suspect you only want to do this for CONTENT_INDEX_DEFAULT.  This would be done in index.php using an if statement to determine if $content == CONTENT_INDEX_DEFAULT , then calling your new page layout at that point..

David

Liquid

  • Newbie
  • *
  • Offline Offline
  • Posts: 14
  • Karma: 2
    • View Profile
Re: Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #3 on: October 06, 2008, 02:33:44 PM »
I'm working on some code to determine if the home page is being served, right now it's inside main_page.tpl.php, then I would do an if-else inside that file to paint a standard template or a special one for a home page.

If I could create an alternate index_page.tpl.php and link that into filenames.php, that'd be great, but it doesn't look like I should be putting code into filenames.php, since it's just defines.

Thanks David for responding with a technique for a clean way to do this.
"Then modify the index files to use it instead for the home page."

My question is:
What are the "index files" that I can modify to substitute the index_page.tpl.php to run only when it's the home page?

David M. Graham

  • Administrator
  • Sr. Member
  • *****
  • Offline Offline
  • Posts: 380
  • Karma: 12
    • View Profile
    • osCommerce University
Re: Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #2 on: October 05, 2008, 07:57:16 AM »
One way to do it would be to setup an alternative "index_page.tpl.php" which works like the main_page.tpl.php but manages the static columns you want and uses its own css and images.  Then modify the index files to use it instead for the home page.

David

Liquid

  • Newbie
  • *
  • Offline Offline
  • Posts: 14
  • Karma: 2
    • View Profile
Custom Home Page with it's own set of infobox options and stylesheet?
« Reply #1 on: October 05, 2008, 02:33:22 AM »
I would like to create a custom home page that has a different background and a minimal set of infoboxes.

So I can't just edit my mainpage.php since that just affects the content area, not the columns, header and stylesheet.

I would use a static page, but that's not an elegant solution, also I'd like to have an infobox or two and the "Items in Cart" up in the header.

Specifically a custom home page:
1) categories4.php and Information_table.php are the only two infoboxes I need in the left column.

2) Show cart in header = yes

3) Entire page background-image needs to be different than the one for the REST of the website.

4) header and footer the same as the rest of the website.

Version: CRE Loaded6 v6.2 B2B White Label[13.2 (SP1)]