77 lines
3.2 KiB
PHP
77 lines
3.2 KiB
PHP
<?php
|
|
class ContentController extends FrontController
|
|
{
|
|
public function process()
|
|
{
|
|
parent::process();
|
|
|
|
$id_lang = self::$cookie->id_lang;
|
|
$id_category = Tools::getValue('cid', 0);
|
|
$id_subcategory = Tools::getValue('sid', 0);
|
|
$id_post = Tools::getValue('id', 0);
|
|
|
|
// Main category
|
|
$sql = "SELECT * FROM ps_guide_category gc, ps_guide_category_lang gcl
|
|
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
|
|
AND gc.id_guide_category=".$id_category." AND gcl.id_lang=".$id_lang;
|
|
$categories = Db::getInstance()->getRow($sql);
|
|
|
|
// Auto Select the subcategory
|
|
if ($id_subcategory == 0) {
|
|
$sql = "SELECT * FROM ps_guide_category gc, ps_guide_category_lang gcl
|
|
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
|
|
AND gc.id_parent=".$id_category." AND gcl.id_lang=".$id_lang.
|
|
" ORDER BY gc.position ASC";
|
|
$subcategories = Db::getInstance()->getRow($sql);
|
|
}
|
|
// Select the subcategory
|
|
else {
|
|
$sql = "SELECT * FROM ps_guide_category gc, ps_guide_category_lang gcl
|
|
WHERE gc.active=1 AND gc.id_guide_category=gcl.id_guide_category
|
|
AND gc.id_guide_category=".$id_subcategory." AND gcl.id_lang=".$id_lang;
|
|
$subcategories = Db::getInstance()->getRow($sql);
|
|
}
|
|
|
|
// Auto select post
|
|
if ($id_post == 0) {
|
|
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
|
|
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
|
|
AND gp.id_guide_category=".$subcategories['id_guide_category'].
|
|
" AND gpl.id_lang=".$id_lang." ORDER BY position ASC";
|
|
$content = Db::getInstance()->getRow($sql);
|
|
}
|
|
// Select post
|
|
else {
|
|
$sql = "SELECT * FROM ps_guide_post gp, ps_guide_post_lang gpl
|
|
WHERE gp.active=1 AND gp.id_guide_post=gpl.id_guide_post
|
|
AND gp.id_guide_category=".$subcategories['id_guide_category']." AND gp.id_guide_post=".$id_post.
|
|
" AND gpl.id_lang=".$id_lang;
|
|
$content = Db::getInstance()->getRow($sql);
|
|
}
|
|
|
|
self::$smarty->assign(array(
|
|
'path' => 'Guide > TODO',
|
|
'id_category' => $id_category,
|
|
'categoryTitle' => $categories['name'],
|
|
'subcategoryTitle' => $subcategories['name'],
|
|
'subcategoryContent' => $subcategories['description'],
|
|
'postTitle' => $content['meta_title'],
|
|
'postContent' => $content['content'],
|
|
));
|
|
|
|
}
|
|
|
|
public function displayContent()
|
|
{
|
|
parent::displayContent();
|
|
|
|
if (is_file(_PS_THEME_DIR_ . 'modules/purchaseguide/views/front/content.tpl')) {
|
|
$tplFile = _PS_THEME_DIR_ . 'modules/purchaseguide/views/front/content.tpl';
|
|
}
|
|
else {
|
|
$tplFile = _PS_MODULE_DIR_ . 'purchaseguide/views/templates/front/content.tpl';
|
|
}
|
|
|
|
self::$smarty->display($tplFile);
|
|
}
|
|
} |