Jump to content

add custom php page prestashop 1.6


Recommended Posts

Hi there, 

 

I've been playing with prestasop 1.6 for about 6 months, my domain is http://zalafa.com, i want to add a single custom php page to prestashop? But i dunno how to achieve it. If i edit those things in prestashop backend CMS module i am afraid i can't do it with {php}{/php} prestashop tpl tags.

 

I have tried inputting some php syntax like '{php}echo "sdf";{/php}' inside page content, but the system prints them literally instead of being interpreted. 

 

http://zalafa.com/en/content/6-cek-resi-disini will go to single php file containing php syntax for pulling records from database about simple listing of customers shipping consignee number.

 

Thanks for your help :)

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

{php}{/php} tags aren't allowed to use in prestashop, so it's not possible to create page in that way

anyway, just wondering, how you wanted to create separated page with these tags? i have no idea ;)

 

 

you need to create front office controller

check this:

http://stackoverflow.com/questions/14336006/create-custom-page-in-prestashop-1-5-3

 

it's based on 1.5.x but the idea is the same for ps 1.6

Link to comment
Share on other sites

{php}{/php} tags aren't allowed to use in prestashop, so it's not possible to create page in that way

anyway, just wondering, how you wanted to create separated page with these tags? i have no idea ;)

 

 

you need to create front office controller

check this:

http://stackoverflow.com/questions/14336006/create-custom-page-in-prestashop-1-5-3

 

it's based on 1.5.x but the idea is the same for ps 1.6

 

Hi Vekia,

 

Yes i have followed those instructions on that link i have created a link for that http://zalafa.com/index.php?controller=CekResi

 

And i have put the cek-resi.tpl file in a folder of public_html/themes/default-bootstrap, and i have also type some strings in that file but the link doesn't show any feedbacks  :(

Link to comment
Share on other sites

{php}{/php} tags aren't allowed to use in prestashop, so it's not possible to create page in that way

anyway, just wondering, how you wanted to create separated page with these tags? i have no idea ;)

 

 

you need to create front office controller

check this:

http://stackoverflow.com/questions/14336006/create-custom-page-in-prestashop-1-5-3

 

it's based on 1.5.x but the idea is the same for ps 1.6

 

Vekia, this is the file content for the controller resides in directory /overrides/controllers/front/

class CekResi extends FrontController {

/**
 *  Initialize controller
 *  @see FrontController::init()
 */
public function init() {
    parent::init();
}

/**
 *  Assign template vars related to page content
 *  @see FrontController::initContent()
 */
public function initContent() {
    parent::initContent();

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

}

 

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

try to place this file in original controllers directory too

/controllers/front/

 

after that remove cache/class_index.php file

refresh page, class index file will be regenerated automatically.

 

uhm yea i follow but no changes at all :mellow: , still blank page http://zalafa.com/index.php?controller=CekResi

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

ops i got this line in error_logs

 

[09-Jul-2014 09:17:43 Asia/Jakarta] PHP Fatal error:  Class 'CekResi' not found in /home/zalafaco/public_html/classes/controller/Controller.php on line 135
Link to comment
Share on other sites

hello

in fact - it works

http://zalafa.com/index.php?controller=CekResi

 

page is blank

it means that there can be some errors in the code in your class

 

 

please turn on error reporting

 

Hi Vekia,

 

Is this the correct way to turn error reporting in prestashop 1.6 from your link http://cart-help.com/topic/60-error-reporting-prestashop-16-15-14-13/

prestashop above v1.5.3
open: config/defines.inc.php
 
find this line: define('_PS_MODE_DEV_', false);
change to look like this: define('_PS_MODE_DEV_', true);
Link to comment
Share on other sites

btw here is my controller CekResiController.php code at those 2 places

class CekResiControllerCore extends FrontController {

/**
 *  Initialize controller
 *  @see FrontController::init()
 */
public function init() {
    parent::init();
}

/**
 *  Assign template vars related to page content
 *  @see FrontController::initContent()
 */
public function initContent() {
    parent::initContent();

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

}

and here is my tpl file, cek-resi.tpl inside public_html/themes/default-bootstrap

cek resi disini

{php}echo "sdf";{/php}
Edited by zalafa (see edit history)
Link to comment
Share on other sites

that's right

it's correct

use this controller name: (class name)

 

 

class CekResiControllerCore extends FrontController {

 

Vekia

 

ok what do you mean by "use this controller name: (class name)"

i am quite confused..

Link to comment
Share on other sites

 

btw here is my controller CekResiController.php code at those 2 places

class CekResiControllerCore extends FrontController {

/**
 *  Initialize controller
 *  @see FrontController::init()
 */
public function init() {
    parent::init();
}

/**
 *  Assign template vars related to page content
 *  @see FrontController::initContent()
 */
public function initContent() {
    parent::initContent();

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

}

and here is my tpl file, cek-resi.tpl inside public_html/themes/default-bootstrap

cek resi disini

{php}echo "sdf";{/php}

 

silly i don't put php tags "<?php ?>" zzz.. :P  thanks vekia

Link to comment
Share on other sites

  • 2 months later...

I followed a lot of tutorials of this thing to create a custom page but a 404 remains, and when I include my page in SEO URLS i've that : 

 

http://www.araclouds.com/index.php?controller=SliderAtoMods

 

[Debug] This page has moved
Please use the following URL instead: http://www.araclouds.com/index.php?controller=atomods

 

... and when i click a 404 again.

 

so there is my SliderAtoModsController.php 

<?php
class SliderAtoModsControllerCore extends FrontController
{
	public $php_self = 'atomods';
	
		public function init() {
			parent::init();
		}


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

I tried to delete the class_index.php everytime I made a change but nothing.

 

I need help, thanks in advance.

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

  • 3 months later...

Hi there

Thanks for sharing this, it helped me alot today :)

 

I got a suplymentary question:

How to add parent site to breadcrumb ?

Lets say I want my custom page to appear as child of My Account, how is that done?

resulting in : Home > My Account > Custom Page

Think its done like this:

{capture name=path}
    <a href="{$link->getPageLink('my-account', true)|escape:'html':'UTF-8'}">
        {l s='My account'}
    </a>
    <span class="navigation-pipe">
        {$navigationPipe}
    </span>
    <span class="navigation_page">
        {l s='Custom Page'}
    </span>
{/capture}
Link to comment
Share on other sites

  • 2 months later...

Hello,I have the same problem but when i create module page

 

I have created my own module in prestashop 1.6, but module page doesn't  shown, prestashop gives me page not found .

My frontController is :

 

class PrcustomeropinionDefaultModuleFrontController extends ModuleFrontController{
     public function init()
     {
       $this->page_name 'opinion'// page_name and body id
       $this->display_column_left true;
       $this->display_column_right true;
       parent::init();
    }

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

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

}

 

form.tpl  is in views/templates/front folder

 

Please, i need your help !!!

Link to comment
Share on other sites

  • 2 years later...
  • 1 month later...

Hello geys this solution work perfectlly with override also.

1/ in the folder /override create page manufacturer-detail.php and put this code:

 

include(dirname(FILE).'/config/config.inc.php'); Controller::getController('ManufacturerDetailController')->run();

Tools::displayFileAsDeprecated();

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

$smarty->display(_PS_THEME_DIR_.'manufacturer-detail.tpl');

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

2/ In the folder /override/controllers/front create page manufacturerDetailController.php and put this code:

class ManufacturerDetailController extends FrontController{

/*public $php_self = 'manufacturer-detail';  */  /* optional */

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

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

 /*  The following code portion is optional.

* Remove the double-slashes to activate the portion * if you want to use external stylesheet and JavaScript for the page. * Create the CSS and JS files in the css and js directories of the theme accordingly */

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

}

3/ in the folder /themes/your-default-theme create page manufacturer-detail.php and put this code:

Hello world

4/ You can go to SEO & URLs in your back office and add new url

You can access tou your page http://yourstore.com/index?controller=ManufacturerDetail

OR

http://yourstore.com/urr-you-have-added-from-back-office

Link to comment
Share on other sites

  • 1 year later...

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