• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Learning building modules
PostPosted: Thu Sep 05, 2019 2:45 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 402
Location: Netherlands
Hi all,

I'm building a module (FAQ's) but have a problem.

This is my code of the default.php :
\$1:
<?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();

?>


Now this is my default.tpl template :
\$1:
<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>


The output of the print_r($questionrow) is :

\$1:
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


So the query is oke (I think)

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.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: [Solved] Learning building modules
PostPosted: Tue Sep 10, 2019 5:51 pm 
Offline
Power Poster
Power Poster

Joined: Wed Jan 25, 2006 11:53 am
Posts: 402
Location: Netherlands
The problem was caused by the read of the array.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting