Jump to content

How to arrange questions in Free FAQ Module


Gowtham

Recommended Posts

I am using F.A.Q. module by Rafael and Joel

 

I am having problems in arranging the questions.

 

I want a question to be displayed last, but it displays only as first question.

 

I deleted the question, entered some questions and again i tried to enter the same question at last. But it displays as first question.

 

Pl. help me out.

 

Regards

Edited by gowtham.go (see edit history)
Link to comment
Share on other sites

Hi, in faq.php there is an SQL query that probably gets the faqs you talk about:

 

function getFaq($id_lang = NULL)
{
 $result = array();
 /* Get id */
 if (!$faqs = Db::getInstance()->ExecuteS('SELECT `id_faq` FROM '._DB_PREFIX_.'faq'))
  return false;
 $i = 0;
 foreach ($faqs AS $faq)
 {
  $result[$i]['id'] = $faq['id_faq'];
  /* Get multilingual text */
  $sql = 'SELECT `id_lang`, `question`, `answer`
   FROM '._DB_PREFIX_.'faq_lang
   WHERE `id_faq`='.intval($faq['id_faq']);
  if (isset($id_lang) AND is_numeric($id_lang) AND intval($id_lang) > 0)
   $sql .= ' AND `id_lang` = '.intval($id_lang);
  if (!$texts = Db::getInstance()->ExecuteS($sql))
   return false;
  foreach ($texts AS $text)
  {
   $result[$i]['question_'.$text['id_lang']] = $text['question'];
   $result[$i]['answer_'.$text['id_lang']] = $text['answer'];
  }
  $i++;
 }
 return $result;
}

 

 

I didn't try it, as I don't have working PS version for it I think, so please try and let me know:

 

add an ORDER BY command:

 

 

 

 

function getFaq($id_lang = NULL)

{

$result = array();

/* Get id */

if (!$faqs = Db::getInstance()->ExecuteS('SELECT `id_faq` FROM '._DB_PREFIX_.'faq'))

return false;

$i = 0;

foreach ($faqs AS $faq)

{

$result[$i]['id'] = $faq['id_faq'];

/* Get multilingual text */

$sql = 'SELECT `id_lang`, `question`, `answer`, `id_faq`

FROM '._DB_PREFIX_.'faq_lang

WHERE `id_faq`='.intval($faq['id_faq']);

if (isset($id_lang) AND is_numeric($id_lang) AND intval($id_lang) > 0)

$sql .= ' AND `id_lang` = '.intval($id_lang);

 

 

$sql .= ' ORDER BY `id_faq`';

 

if (!$texts = Db::getInstance()->ExecuteS($sql))

return false;

foreach ($texts AS $text)

{

$result[$i]['question_'.$text['id_lang']] = $text['question'];

$result[$i]['answer_'.$text['id_lang']] = $text['answer'];

}

$i++;

}

return $result;

}

 

 

Just add all red text. But careful!!, `id_faq` has special quotes! Just copy from code above.

It now orders the faq's by id number, so probably in order of adding a faq. If you want it in reverse

 

change it into:

 

 

$sql .= ' ORDER BY `id_faq` DESC';

 

 

Hope this does the trick

 

pascal

 

 

PS. Tomorrow I fly to Holland, so not online for a day or two. If any problem in the mean time, maybe someone can pick it up???

  • Like 1
Link to comment
Share on other sites

hello

 

unfortunately it isnt default module so it's hard to say what you have to do. If module is free - can you please share the url to the thread where we can download module package?

 

Hi vekia,

 

Pl. find the download link for free F.A.Q. module for ps 1.5 below.

 

http://www.prestasho...attach_id=65698

 

If you can't download it, give a visit to this thread

 

http://www.prestasho...0/page__st__380

 

Regards

Edited by gowtham.go (see edit history)
Link to comment
Share on other sites

Hi, in faq.php there is an SQL query that probably gets the faqs you talk about:

 

function getFaq($id_lang = NULL)
{
 $result = array();
 /* Get id */
 if (!$faqs = Db::getInstance()->ExecuteS('SELECT `id_faq` FROM '._DB_PREFIX_.'faq'))
  return false;
 $i = 0;
 foreach ($faqs AS $faq)
 {
  $result[$i]['id'] = $faq['id_faq'];
  /* Get multilingual text */
  $sql = 'SELECT `id_lang`, `question`, `answer`
FROM '._DB_PREFIX_.'faq_lang
WHERE `id_faq`='.intval($faq['id_faq']);
  if (isset($id_lang) AND is_numeric($id_lang) AND intval($id_lang) > 0)
$sql .= ' AND `id_lang` = '.intval($id_lang);
  if (!$texts = Db::getInstance()->ExecuteS($sql))
return false;
  foreach ($texts AS $text)
  {
$result[$i]['question_'.$text['id_lang']] = $text['question'];
$result[$i]['answer_'.$text['id_lang']] = $text['answer'];
  }
  $i++;
 }
 return $result;
}

 

 

I didn't try it, as I don't have working PS version for it I think, so please try and let me know:

 

add an ORDER BY command:

 

 

 

 

function getFaq($id_lang = NULL)

{

$result = array();

/* Get id */

if (!$faqs = Db::getInstance()->ExecuteS('SELECT `id_faq` FROM '._DB_PREFIX_.'faq'))

return false;

$i = 0;

foreach ($faqs AS $faq)

{

$result[$i]['id'] = $faq['id_faq'];

/* Get multilingual text */

$sql = 'SELECT `id_lang`, `question`, `answer`, `id_faq`

FROM '._DB_PREFIX_.'faq_lang

WHERE `id_faq`='.intval($faq['id_faq']);

if (isset($id_lang) AND is_numeric($id_lang) AND intval($id_lang) > 0)

$sql .= ' AND `id_lang` = '.intval($id_lang);

 

 

$sql .= ' ORDER BY `id_faq`';

 

if (!$texts = Db::getInstance()->ExecuteS($sql))

return false;

foreach ($texts AS $text)

{

$result[$i]['question_'.$text['id_lang']] = $text['question'];

$result[$i]['answer_'.$text['id_lang']] = $text['answer'];

}

$i++;

}

return $result;

}

 

 

Just add all red text. But careful!!, `id_faq` has special quotes! Just copy from code above.

It now orders the faq's by id number, so probably in order of adding a faq. If you want it in reverse

 

change it into:

 

 

$sql .= ' ORDER BY `id_faq` DESC';

 

 

Hope this does the trick

 

pascal

 

 

PS. Tomorrow I fly to Holland, so not online for a day or two. If any problem in the mean time, maybe someone can pick it up???

 

Thanks for your reply Pascal.

 

I gave it a try, but it don't seem to work.

 

I added the codes in red from your post to faq.php

 

The id number for the question is 16, but it displays as first question.

 

You can visit the page in http://www.yoobig.com/modules/faq/faqs.php

 

Regards

Edited by gowtham.go (see edit history)
Link to comment
Share on other sites

Did you add the DESC or not? If you add it, the latest FAQ is at the top. If you want it at the end, leave it out (will try to try tonight myself if it works or not...

 

Hi Pascal

I did try that and there is no change in the order.

 

Regards

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...