Hi guys,
Has anyone ever managed to do this, create a custom page (not through the admin function to create a page) and have this page run a query to a database to extract data? I’ve looked through google and can’t find any suggestion as how to do this so thought I would ask here. Prestashop uses the ‘Smarty’ template engine, which to be honest I have no idea on how to use. I have managed to add a new page and the template for the page in the theme (thanks to some nice person who shared their work for all to use).
It works great for a static page but I need to have it dynamic. I’ve looked through other template files which use a query but I can’t see how it’s done. Does anyone have an idea or a link to how to do this?
Cheers
I guess no one has but maybe if I show what I’ve got so far, someone can help maybe. Basically I’ve added a table to the database called towns and this table has a list of towns each with an id. All I want to do is show the towns on the page using the code below.
Right, I have got a result to show but it displays ‘array’ on the page. Here’s my php code
<?php
include(dirname(__FILE__).'/config/config.inc.php');
if(intval(Configuration::get('PS_REWRITING_SETTINGS')) === 1)
$rewrited_url = __PS_BASE_URI__;
include(dirname(__FILE__).'/header.php');
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT `town_name`
FROM `ps_towns`');
$towns = array();
foreach($results as $result) {
$towns[] = $result['town_name'];
}
echo $towns;
$smarty->display(_PS_THEME_DIR_.'newpage.tpl');
include(dirname(__FILE__).'/footer.php');
?>
This topic can be closed as I’ve managed to sort it myself