single.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. include_once dirname(__FILE__).'/../../classes/chcreapost.php';
  3. class ChcreateursingleModuleFrontController extends ModuleFrontController
  4. {
  5. public function __construct()
  6. {
  7. parent::__construct();
  8. $this->controller_type = 'modulefront';
  9. $this->page_name = $this->module->name.'-single';
  10. }
  11. public function init()
  12. {
  13. parent::init();
  14. $rewrite = Tools::getValue('rewrite');
  15. $this->id_chcreaposts = Tools::getValue('id');
  16. $this->chcreapost = Chcreapost::getSinglePost($this->id_chcreaposts);
  17. }
  18. public function setMedia($isNewTheme = false)
  19. {
  20. parent::setMedia();
  21. $this->context->controller->addJS(chcrea_js_dir.'chslider.js');
  22. }
  23. public function initContent()
  24. {
  25. parent::initContent();
  26. $chcreavars = [];
  27. $chcreavars['name'] = $this->chcreapost['meta_title'];
  28. $chcreavars['description'] = $this->chcreapost['meta_description'];
  29. $chcreavars['class'] = $this->module->name.'_post';
  30. $this->context->smarty->assign('chvars', $chcreavars);
  31. $this->context->smarty->assign('chpost', $this->chcreapost);
  32. $this->context->smarty->assign('disable_blog_com', true);
  33. $postNext = Chcreapost::getNextPost($this->chcreapost['position']);
  34. $postPrevieus = Chcreapost::getPreviousPost($this->chcreapost['position']);
  35. //print("next/previous:".$postNext." ".$postPrevieus);
  36. if (is_array($postNext) && count($postNext) > 0) {
  37. $this->context->smarty->assign('link_post_next', $postNext['link']);
  38. }
  39. if (is_array($postPrevieus) && count($postPrevieus) > 0) {
  40. $this->context->smarty->assign('link_post_previeus', $postPrevieus['link']);
  41. }
  42. $this->setTemplate('module:'.$this->module->name.'/views/templates/front/single.tpl');
  43. }
  44. public function getBreadcrumbLinks()
  45. {
  46. $breadcrumb = parent::getBreadcrumbLinks();
  47. $breadcrumb['links'][] = [
  48. 'title' => Configuration::get(strtoupper($this->module->name).'_TITLE'),
  49. 'url' => '/noscreateurs',
  50. ];
  51. $breadcrumb['links'][] = [
  52. 'title' => $this->chcreapost['post_title'],
  53. 'url' => $this->chcreapost['link'],
  54. ];
  55. return $breadcrumb;
  56. }
  57. }