Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 378 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prestashop custom page with own template

#1
I am running my own prestashop theme and want to add a new page without the css.
Therefore I added the three files php, controller and template. I placed the php in the root directory of my prestashop, added the controller to root/controllers/front and placed the template in root/themes/my-theme.
If I call

[To see links please register here]

, I see the index start page, If I call localhost/prestashop/custom-page, I get a HTTP 404.
Can someone help me to get my page displayed?

PHP:

<?php
include(dirname(__FILE__).'/config/config.inc.php');
Tools::displayFileAsDeprecated();

include(dirname(__FILE__).'/header.php');

$smarty->display(_PS_THEME_DIR_.'custom-page.tpl');

include(dirname(__FILE__).'/footer.php');

Controller:

<?php
class CustomPageController extends FrontController{

public function init(){
parent::init();
}

public function initContent(){
parent::initContent();
$this->setTemplate(_PS_THEME_DIR_.'custom-page.tpl');
}


//public function setMedia(){
//parent::setMedia();
//$this->addCSS(_THEME_CSS_DIR_.'custom-page.css');
//$this->addJS(_THEME_JS_DIR_.'custom-page.js');
//}

}

Template:

<div>
HELLO PAGE
</div>

{literal}
<style type="text/css">
</style>
{/literal}

<script type="text/javascript">
{literal}
{/literal}
</script>
Reply

#2
I think the best practice would be to create a module with your custom page. Because with your approach you may get troubles after prestashop update and also a behavior of your store may be unpredictable with different properties.

Here is some information about how to create own page within a module

[To see links please register here]

and

[To see links please register here]

Reply

#3
For PS 1.7, create a new page following the next steps:

**Create the controller**: `/controllers/front/MyPageController.php`

<?php

class MyPageControllerCore extends FrontController
{
public $php_self = 'mypage';
public $ssl = true;

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

$this->setTemplate('mypage');
}
}

**Create the tpl file in your theme**: `/themes/YOUR_THEME/templates/mypage.tpl`

{extends file='page.tpl'}

{block name='page_header_container'}{/block}

{block name='page_content'}
PAGE CONTENT HERE
{/block}

**Delete the class index files**: `/var/cache/dev/class_index.php` and `/var/cache/prod/class_index.php`

**How to access it**: `http://your-site.com/index.php?controller=mypage`

**Finally**:
If you want to handle a friendly URL for this page, just add the page in `Shop Parameters > Traffic & SEO`.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through