Jump to content

Landing Page Configuration Newb Question


Recommended Posts

Hello,
 
I want to change the landing page to my cms front page but still keep the normal shop front page for my shop.
 
I kind of figured it out I think
 
I copied IndexController.php from /controllers/ and put it inside /overide/controllers and changed it from
 

class IndexControllerCore extends FrontController
{
	public $php_self = 'index';

	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	public function initContent()
	{
		parent::initContent();
		$this->addJS(_THEME_JS_DIR_.'index.js');

		$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 
			'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
			'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')
		));
		$this->setTemplate(_PS_THEME_DIR_.'index.tpl');
	}
}

To
 

class IndexControllerCore extends FrontController
{
	public $php_self = 'index';

	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	public function initContent()
	{
		Tools::redirect('http://matonostalgi.se/content/8-frontpage');
	}
}

Now I need to create a new blank page without making a cms page so I just used best sellers as an example to try out my teory.

So I copied BestSalesController.php from /controllers/ and put it inside /override/controllers aswell.

then I changed BestSalesController from
 

class BestSalesControllerCore extends FrontController
{
	public $php_self = 'best-sales';

	public function initContent()
	{
		if (Configuration::get('PS_DISPLAY_BEST_SELLERS'))
		{
			parent::initContent();
	
			$this->productSort();
			$nbProducts = (int)ProductSale::getNbSales();
			$this->pagination($nbProducts);
	
			$products = ProductSale::getBestSales($this->context->language->id, $this->p - 1, $this->n, $this->orderBy, $this->orderWay);
			$this->addColorsToProductList($products);
	
			$this->context->smarty->assign(array(
				'products' => $products,
				'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
				'nbProducts' => $nbProducts,
				'homeSize' => Image::getSize(ImageType::getFormatedName('home')),
				'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')
			));
	
			$this->setTemplate(_PS_THEME_DIR_.'best-sales.tpl');
		}
		else
			Tools::redirect('index.php?controller=404');
	}

	public function setMedia()
	{
		parent::setMedia();
		$this->addCSS(_THEME_CSS_DIR_.'product_list.css');
	}
}

To
 

class BestSalesControllerCore extends FrontController
{
	public $php_self = 'best-sales';

	public function initContent()
	{
		parent::initContent();
		$this->addJS(_THEME_JS_DIR_.'index.js');

		$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'), 
			'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
			'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')
		));
		$this->setTemplate(_PS_THEME_DIR_.'index.tpl');
	}

}

Is there any better way to do this ?

 

Homeslider does not show and new products block need to be refresh by clicking back and forth from best seller or popular block

 

Any ideas why ?

Edited by Eke (see edit history)
Link to comment
Share on other sites

If you use redirect, the user will be sent to the other page, not kept on the index with a different template, is that what you want? That said, you should redirect within init() and not initContent() ;)

Link to comment
Share on other sites

If you use redirect, the user will be sent to the other page, not kept on the index with a different template, is that what you want? That said, you should redirect within init() and not initContent() ;)

 

No I rather have them kept on the index with a other template but how do I do that ?

 

Also how do I keep the index template too create a shop frontpage with it ?

 

Edit: My page is exactly how I want it to be, users just end up in the wrong place 

Edited by Eke (see edit history)
Link to comment
Share on other sites

Wrong place: wrong url?

 

Wrong place as in index should be "FrontPage" and the standard index page should be "FrontShopPage" 

 

My page looks exactly like I want it to be, I only want to change landing page but still keep index page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...