Jump to content

CMS page as homepage


Recommended Posts

Hi vekia,
 
Thanks for your input. Looks like the module adds the contrent of a cms page into my homepage.
What i'd like is to define a CMS page as home page
 
The idea behind this is to have a "traditionnal website" with a shop, the menu would look like this :
 
Index / Home page (cms page) / About us (cms page) / Contact us / Shop (Prestashop index page)
 
Is it possible ?

Link to comment
Share on other sites

if you want to create a cms page as a shop homepage - it is possible but only with controller modification.

for example, we have CMS page with ID 4. and we want to use it as a homapge.

 

 

go to:

controllers/front/IndexController.php

 

replace contents of this file with:
 

<?php
/*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

class IndexControllerCore extends FrontController
{
	public $php_self = 'cms';
	public $assignCase;
	public $cms;
	public $cms_category;
	public $ssl = false;

	public function canonicalRedirection($canonicalURL = '')
	{
		if (Tools::getValue('live_edit'))
			return;
		if (Validate::isLoadedObject($this->cms) && ($canonicalURL = $this->context->link->getCMSLink($this->cms, $this->cms->link_rewrite, $this->ssl)))
			parent::canonicalRedirection($canonicalURL);
		elseif (Validate::isLoadedObject($this->cms_category) && ($canonicalURL = $this->context->link->getCMSCategoryLink($this->cms_category)))
			parent::canonicalRedirection($canonicalURL);
	}

	/**
	 * Initialize cms controller
	 * @see FrontController::init()
	 */
	public function init()
	{


		parent::init();


	}

	public function setMedia()
	{
		parent::setMedia();

		if ($this->assignCase == 1)
			$this->addJS(_THEME_JS_DIR_.'cms.js');

		$this->addCSS(_THEME_CSS_DIR_.'cms.css');
	}

	/**
	 * Assign template vars related to page content
	 * @see FrontController::initContent()
	 */
	public function initContent()
	{
		parent::initContent();
        $id_cms=4;
            $this->cms = new CMS($id_cms, $this->context->language->id);
			$this->context->smarty->assign(array(
				'cms' => $this->cms,
				'content_only' => (int)Tools::getValue('content_only'),
				'path' => $path,
				'body_classes' => array($this->php_self.'-'.$this->cms->id, $this->php_self.'-'.$this->cms->link_rewrite)
			));


		$this->setTemplate(_PS_THEME_DIR_.'cms.tpl');
	}
}


you can find there code: $id_cms=4;

 

just change value of this variable to display another cms page. (4 is a id of cms page)

  • Like 1
Link to comment
Share on other sites

Hi Vekia, it works great tyvm !

 

But now, how would I make a link to old index in my horizontal menu ?

Index (cms page) / About us (cms page) / Contact us (cms page/ Visit our Shop (Prestashop index page)

 

I'd like a traditional website to present our company + a store (as catalog).

 

Cheers

Link to comment
Share on other sites

  • 10 months later...
  • 4 weeks later...

First of all Happy New Year!

 

I understand the issue of Kuroko and indeed I have the same question.

After you change the default home page with your sript to a CMS page, how to create a link in the menu pointing to the home page by default of prestashop, not the cms home page ? I am clear !!!!
Edited by lestyx (see edit history)
  • Like 1
Link to comment
Share on other sites

I expressed myself badly, sorry.

 

My question is:

 

before the change of "IndexController.php" the index of my site was the home page the default index page off prestashop,
after editing the file "IndexController.php"
how can I call home page the default index page off prestashop? not the new cms page
 
creating a second "IndexController.php" as IndexController2.php ???
Edited by lestyx (see edit history)
Link to comment
Share on other sites

  • 8 months later...

I am having same questions as well.

 

Thank you to vekia, I got the cms page as homepage now, but I lost the old default homepage link, can you please help, what should I do to get the old default homepage to become the Shop menu button link please?

 

just type url to your shop front office main page and this should be enough to create "homepage" menu item

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

  • 3 years later...

I have the same question

how to create a prestashop with this menu 

 

Home (cms page) / About us (cms page) / Contact us (cms page) / Visit our Shop (Prestashop index page)

I thinks the request as very clear

However I find something usefull but I could not apply it 😕

Here: https://www.brontobytes.com/knowledgebase/202/.htaccess-URL-Masking-Examples.html?language=english&currency=7

Quote

Example 1

#Show content from a different path on the same domain
#This way each time someone accesses yourdomain.com/path the actual content that will be displayed will be for yourdomain.com/different/path while the URL will remain unchanged.
RewriteEngine On
RewriteRule ^path/?$ /different/path/
 

Example 2

#Redirect and keep everything after the URL
#Visit yourdomainA.com/page and it will show the content from yourdomainB.com/page
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomainA.com
RewriteRule ^(.*) http://www.yourdomainB.com/$1 [P]

Can any one apply it ?

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...