Jump to content

[SOLVED] Simple Custom Page


Recommended Posts

What's the best way to create a simple custom page inside PrestaShop that includes just the header, the footer and some custom content in between? I assume I can just copy an already existing PHP and corresponding TPL file, rename them and then edit them like that? Which is the best one to copy?

Link to comment
Share on other sites

I think prices-drop.php is a pretty simple page that you can use as a guide for what to do, though it doesn't import init.php. Here's a template you can use:

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
include(dirname(__FILE__).'/header.php');

$smarty->assign(array('variable1' => 'value1', 'variable2', 'value2'));
$smarty->display(_PS_THEME_DIR_.'custom.tpl');

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

?>



This code will make all of Prestashop's variables accessible to your template, display the header, call the custom template in your theme (passing variable1 and variable2 into the custom template) for the content of the page, then display the footer.

Link to comment
Share on other sites

Excuse my noobiness, but just so I know, what do the following two lines mean?

include(dirname(__FILE__).'/init.php'); - What is init.php?
$smarty->assign(array('variable1' => 'value1', 'variable2', 'value2')); - What are these variables?

Cheers!

Link to comment
Share on other sites

The file init.php declares many of Prestashop's variables like $cookie, which will allow your custom.tpl to access lots of useful information. On the second line, I made up variable1 and variable2 to show you how to pass your own custom variables into custom.tpl.

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