Page 1 of 1

Change store home to be a category page

Posted: Tue Aug 24, 2010 6:30 am
by edbloom
Hi all,

I want to change my home template to actually be one of my category pages.

Now before I go creating a new controller and output all the values into the home.tpl file is there a better more efficient way of doing this?

Thanks,

Ed

Re: Change store home to be a category page

Posted: Tue Aug 24, 2010 8:08 am
by JAY6390
Open up

Code: Select all

/catalog/controller/common/home.php
and just after

Code: Select all

public function index() { 
on a new line put

Code: Select all

$this->redirect(HTTP_SERVER . 'index.php?route=product/category&path=20_27'); 
changing the 20_27 to the correct category path

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 2:26 am
by edbloom
Jay,

my friend you are a genius!

you probably just saved me a couple of hours of writing a module to output the category listing.

thanks so much!

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 3:35 am
by JAY6390
lol no problem. At the most, you'd just have to duplicate the category controller and view, and then save them in the home controller and view files respectively :)

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 3:37 am
by edbloom
that's what I was about to do but your solution works perfectly!

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 3:48 am
by JAY6390
hehe glad its all sorted :)

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:23 am
by edbloom
ahh
slight snag with this neat little solution

it's messed up the currency switcher.

i assume something in home.php which normally sets the currency session value is no longer getting called as a result of the redirect kicking in.

this would make sense if I was on the home page but doesn't make sense on a category page.

what happens is that the refresh occurs but the session value does not change.

I'm looking into it right now...

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:29 am
by edbloom
so what seems to be happening is that say I'm on the cart page and switch from sterling to euro.... instead of the page refreshing and the currency switching - I get redirected back to my category page that I've set in home.php

I wonder why the cart page (or any other page for that matter) is intercepting a redirect that is set in home.php - surely this line I added would only intercept any requests to home...

strange...

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:32 am
by edbloom
what's also even stranger is that the form redirect is being set correctly on each page

e.g.

<input type="hidden" name="redirect" value="http://localhost.dev/opencart/index.php ... ckout/cart

is where the form redirect is set to go when on the cart page - not the product category page

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:39 am
by JAY6390
I thought I answered this. Are you sure you've edited home.php and not header.php by mistake?

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:53 am
by edbloom
Hi Jay,

I thought I had too - but I've double and triple checked - I definitely edited home.php not header.php

very odd

Re: Change store home to be a category page

Posted: Wed Aug 25, 2010 4:55 am
by edbloom
I recreated the issue on a clean install just to be sure aswell...

Re: Change store home to be a category page

Posted: Thu Aug 26, 2010 4:45 am
by edbloom
hmmm - racking my brains and still can't figure this one out - any ideas?

Re: Change store home to be a category page

Posted: Fri Dec 04, 2020 3:19 am
by robinpecha
Hi, in opencart 3 it doesnt work, whole page freeze. Please any updated solution?