I'm building a module (FAQ's) but have a problem.
This is my code of the default.php :
Code: Select all
<?php
if( !defined('CMS_VERSION') ) exit;
$query = new CategoryQuery;
$categorys = $query->GetMatches();
$sql = 'SELECT * FROM '.CMS_DB_PREFIX.'mod_msfaq_questions WHERE category = "Category 1"';
$questionrow = $db->GetArray($sql);
print_r($questionrow);
$out = NULL;
foreach( $questionrow as $row ) {
$out[$row['question']] = trim($row['question']);
}
$tpl = $smarty->CreateTemplate($this->GetTemplateResource('default.tpl'),null,null,$smarty);
$tpl->assign('categorys',$categorys);
$tpl->assign('questions',$out);
$tpl->display();
?>
Code: Select all
<div class="msfaq_wrapper">
test
{foreach $categorys as $category}
<div class="category">
<div class="row">
<div class="categoryline"><a href="{cms_action_url action='categoryquestions' cid=$category->id}">{$category->category_name}</a>
</div>
</div>
</div>
{foreachelse}
<div class=”noquestions”>{$mod->Lang('noquestion')}</div>
{/foreach}
{foreach $questions as $question}
<div class="questions">
<div class="row">
<div class="questionline">{$question->question} {$question->answer}
</div>
</div>
</div>
{/foreach}
</div>
Code: Select all
Array ( [0] => Array ( [id] => 11 [category] => Category 1 [question] => Vraag 1 [answer] =>
Datum test
[creation_date] => 0 [modified_date] => 0 ) [1] => Array ( [id] => 12 [category] => Category 1 [question] => Vraag 2 [answer] =>
Datum Test 2
[creation_date] => 2019 [modified_date] => 0 ) [2] => Array ( [id] => 13 [category] => Category 1 [question] => Vraag 5 [answer] =>
Test 5 dsatum
[creation_date] => 1567202400 [modified_date] => 0 ) )
test
Please help. Why is there no output on the screen showing the questions ?
The categories are showing oke.
Please help. I want to learn make cmsms modules.