<?php

defined('COT_CODE') or die('Wrong URL');

$out['subtitle'] = 'Вопрос-ответ';

$id = cot_import('article', 'G', 'INT');

$mskin = cot_tplfile(array('faq'), 'module');

/* === Hook === */
foreach (cot_getextplugins('faq.list.main') as $pl)
{
	include $pl;
}
/* ===== */

$t = new XTemplate($mskin);

$render = cot_faq_render(0, false);
$render = cot_faq_postrender($render);

$atricle = '';
if($id > 0) {
  foreach($render as $rend) {
    if($id == $rend['id']) {
      $atricle = $rend;
      break;
    }
  }
}

$t->assign(array(
  'FAQ_ARTICLES_JSON' => base64_encode(json_encode($render)),
  'FAQ_ARTICLE_JSON' => (is_array($atricle) ? base64_encode(json_encode($atricle)) : ''),
  'TEST' => json_encode($atricle),
));

/* === Hook === */
foreach (cot_getextplugins('faq.list.tags') as $pl)
{
	include $pl;
}
/* ===== */

$t->parse('MAIN');
$module_body = $t->text('MAIN');