Author |
Message |
transit
Regular
![Regular Regular](modules/Forums/images/ranks/2stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jun 01, 2010
Posts: 69
|
Posted:
Mon Oct 04, 2010 7:36 pm |
|
So I started to try to change the way the FAQ module displays itself. It is a very useful module, however in reality I will never have more than 5-7 categories for my FAQ. So what I have tried to do is display all of the FAQ categories above every FAQ so that at any time the user can switch categories without having to go back to the "Main" page to select their category.
The problem it screws up the list of question links by showing the list for the last category on the list as opposed to the current FAQ selected. All of the Q and A's show correctly below, but the quick list of "Questions" is for the last category in the list for every category! Take a look here and see for yourself!
I could use as much help with this as possible! Thanks alot in advance!
http://trott.ca/trott/faq-1-Frequently+Asked+Questions+for+Charters.html
Take this code here from the original FAQ
Code:
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file;
$categories = htmlentities($categories);
OpenTable();
echo '<center><font class="content"><b>'.$sitename.' '._FAQ2.'</b></font></center><br /><br />'
.'<a name="top"></a><br />'
._CATEGORY.': <a href="modules.php?name='.$module_name.'">'._MAIN.'</a> -> '.$categories
.'<br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
|
And after line 78 of FAQ\index.php add this
Code: OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result2)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
|
Which is pretty much the data copied from above in the index.php to show the categories on the main page for this module. I obviously need to change some syntax within to mesh the categories being displayed on the same page as each faq without interfering!
Here is the entire FAQ/index.php right now.
Code:
<?php
/***************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* ======================== */
/* Based on PHP-Nuke Add-On */
/* Copyright (c) 2001 by Richard Tirtadji AKA King Richard */
/* (rtirtadji@hotmail.com) */
/* Hutdik Hermawan AKA hotFix */
/* (hutdik76@hotmail.com) */
/* http://www.nukeaddon.com */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/***************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/***************************************************************************/
if ( !defined('MODULE_FILE') ) {
die('You can\'t access this file directly...');
}
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '.$module_name;
if (!isset($myfaq)) {
global $currentlang, $multilingual;
if ($multilingual == 1) {
$querylang = 'WHERE flanguage=\''.$currentlang.'\'';
} else {
$querylang = '';
}
include_once('header.php');
OpenTable();
echo '<center><span class="option">'._FAQ2.'</span></center><br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result2 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result2)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatEdit&id_cat='.$id_cat.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatDel&id_cat='.$id_cat.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
include_once('footer.php');
} else {
include_once('header.php');
ShowFaq($id_cat, $categories);
ShowFaqAll($id_cat);
CloseTable();
include_once('footer.php');
}
die();
//Only functions after this line
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file;
$categories = htmlentities($categories);
OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result2)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
OpenTable();
echo '<center><font class="content"><b>'.$sitename.' '._FAQ2.'</b></font></center><br /><br />'
.'<a name="top"></a><br />'
._CATEGORY.': <a href="modules.php?name='.$module_name.'">'._MAIN.'</a> -> '.$categories
.'<br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
function ShowFaqAll($id_cat) {
global $bgcolor2, $prefix, $db, $module_name;
$id_cat = intval($id_cat);
echo '<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'._ANSWER.'</b></font></td></tr>';
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<tr><td><a name="'.$id.'"></a>'
.'<strong><big>·</big></strong> <b>'.$question.'</b>'
.'<div align="justify">'.$answer.'</div>'
.'[ <a href="#top">'._BACKTOTOP.'</a> ]'
.'<br /><br />'
.'</td></tr>';
}
echo '</table><br /><br />'
.'<div align="center"><b>[ <a href="modules.php?name='.$module_name.'">'._BACKTOFAQINDEX.'</a> ]</b></div>';
}
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
kguske
Site Admin
![](modules/Forums/images/avatars/41f0b40a419280935f3a0.gif)
Joined: Jun 04, 2004
Posts: 6437
|
Posted:
Wed Oct 06, 2010 1:19 pm |
|
Haven't had a chance to review the code, but it might a shortlinks issue. Have you tried it without using shortlinks? |
_________________ I search, therefore I exist...
Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Oct 08, 2010 7:02 am |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
Site Admin
![](modules/Forums/images/avatars/Dilbert/Dilbert_-_Dogbert_King.gif)
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Fri Oct 08, 2010 12:07 pm |
|
It is because you are using $result2 instead of $result3in your ShowFaq function. From what I can tell you should not be passing $categories into the ShowFaq function. Also you should not be stripping slashes on data coming out of the database. I know it might have been that way before, but it is wrong. |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Oct 08, 2010 12:09 pm |
|
Also when writing scripts you should have error reporting turned on because this problem would have shown up as an undefined variable. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Oct 08, 2010 5:46 pm |
|
So your saying on line 85 i should change it to this?
Code:
while ($row2 = $db->sql_fetchrow($result3)) {
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Fri Oct 08, 2010 7:19 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 11, 2010 10:15 am |
|
No dice. This is my script with that minor change...
The FAQ can be seen here:
http://completesolar.ca/modules.php?name=FAQ&myfaq=yes&id_cat=2&categories=FAQ
Code:
<?php
/***************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* ======================== */
/* Based on PHP-Nuke Add-On */
/* Copyright (c) 2001 by Richard Tirtadji AKA King Richard */
/* (rtirtadji@hotmail.com) */
/* Hutdik Hermawan AKA hotFix */
/* (hutdik76@hotmail.com) */
/* http://www.nukeaddon.com */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/***************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/***************************************************************************/
if ( !defined('MODULE_FILE') ) {
die('You can\'t access this file directly...');
}
require_once('mainfile.php');
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = '- '.$module_name;
if (!isset($myfaq)) {
global $currentlang, $multilingual;
if ($multilingual == 1) {
$querylang = 'WHERE flanguage=\''.$currentlang.'\'';
} else {
$querylang = '';
}
include_once('header.php');
OpenTable();
echo '<center><span class="option">'._FAQ2.'</span></center><br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result2 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result2)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatEdit&id_cat='.$id_cat.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatDel&id_cat='.$id_cat.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
include_once('footer.php');
} else {
include_once('header.php');
ShowFaq($id_cat, $categories);
ShowFaqAll($id_cat);
CloseTable();
include_once('footer.php');
}
die();
//Only functions after this line
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file;
$categories = htmlentities($categories);
OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result3)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
OpenTable();
echo '<a name="top"></a><br /><b>'
._CATEGORY.': '.$categories
.'<br /><br /></b>'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
function ShowFaqAll($id_cat) {
global $bgcolor2, $prefix, $db, $module_name;
$id_cat = intval($id_cat);
echo '<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'._ANSWER.'</b></font></td></tr>';
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<tr><td><a name="'.$id.'"></a>'
.'<strong><big>·</big></strong> <b>'.$question.'</b>'
.'<div align="justify">'.$answer.'</div>'
.'[ <a href="#top">'._BACKTOTOP.'</a> ]'
.'<br /><br />'
.'</td></tr>';
}
echo '</table><br /><br />'
.'<div align="center"><b>[ <a href="modules.php?name='.$module_name.'">'._BACKTOFAQINDEX.'</a> ]</b></div>';
}
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon Oct 11, 2010 10:58 am |
|
You need to do another database query to get the proper category based on the id around line 97.
Code:
echo '<a name="top"></a><br /><b>'
._CATEGORY.': '.$categories
.'<br /><br /></b>'
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 04, 2010 4:37 pm |
|
I added $categories into the global statement I am a little lost here with this What I am guessing is happening is that the data I am posting for the faqcategories is already being pulled later on in the function so it is becoming redundent thus causing the error in showing the quick links for the faq questions?
I made the changes of both results being 3 instead of two on both instances below too I am guessing.
Code:
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result3)) {
|
Any help Pablin would be greatly appreciated!
Below is the function for this section of the FAQ.
Code:
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file, $categories;
$categories = htmlentities($categories);
//Below table for category list insertion at the top of every faq
OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result3)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
OpenTable();
echo '<a name="top"></a><br /><b>'
._CATEGORY.': '.$categories
.'<br /><br /></b>'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Nov 04, 2010 5:48 pm |
|
You are trying to use the same variable "categories" for two different things. You can not do that. You are expecting it to hold the value passed by the url ....s&id_cat=3&categories=FAQ2, but then you you use it in your while loop:
Code:
while ($row2 = $db->sql_fetchrow($result3)) {
$id_cat = intval($row2['id_cat']);
$categories = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname = urlencode($categories);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat.'&categories='.$catname.'">'.$categories.'</a>';
echo '<br />';
}
|
So $categories is always going to be the last value from your while loop.
Remove $categories from the global statement and use a different variable name in the while loop. Perhaps use $category in the while loop as that is more representative to what is actually happening. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Nov 13, 2010 4:32 pm |
|
Works alot better, turns out i had to change id_cat to id_cat2 as well as catname to catname2 as they are also redundant in the same function:
This is what I changed it to here:
Code:
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file, $categories;
$categories = htmlentities($categories);
//Below table for category list insertion at the top of every faq
OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result3)) {
$id_cat2 = intval($row2['id_cat']);
$category = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname2 = urlencode($category);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat2.'&category='.$catname2.'">'.$category.'</a>';
echo '<br />';
}
echo '</td></tr></table>';
CloseTable();
OpenTable();
echo '<a name="top"></a><br /><b>'
._CATEGORY.': '.$categories
.'<br /><br /></b>'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
|
It works fine, however now I have problems with the right link redirecting, thus to shortlinks.
Here is what I have changed in shortlinks however I must have something wrong!
.htaccess file
Code:
#FAQ
RewriteRule ^faq.html faq.html [L]
RewriteRule ^faq-([0-9]*)-([a-zA-Z0-9\+\&\-\/%[:punct:]\.\;\ ]*).html modules.php?name=FAQ&myfaq=yes&id_cat2=$1&category=$2 [L]
|
GT-FAQ.php
Code:
<?php
/************************************************************************
* Script: TegoNuke(tm) ShortLinks
* Version: 1.0
* Author: Rob Herder (aka: montego) of http://montegoscripts.com
* Contact: montego@montegoscripts.com
* Copyright: Copyright © 2006 by Montego Scripts
* License: GNU/GPL (see provided LICENSE.txt file)
************************************************************************/
//GT-NExtGEn 0.4/0.5 by Bill Murrin (Audioslaved) http://gt.audioslaved.com (c) 2004
//Original Nukecops GoogleTap done by NukeCops (http://www.nukecops.com)
$urlin = array(
'"(?<!/)modules.php\?name=FAQ&myfaq=yes&id_cat2=([0-9]*)&category=([a-zA-Z0-9\.\+\&\-\/\;% ]*)"',
'"(?<!/)modules.php\?name=FAQ"'
);
$urlout = array(
'faq-\\1-\\2.html',
'faq.html'
);
?>
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Palbin
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sat Nov 13, 2010 5:02 pm |
|
The link is not changing so why are you messing with shortlinks? The link you are making is still going to be the same you are just using different variables to create it.
It will still be
Code:&myfaq=yes&id_cat=XX&category=XXXX
|
Not
Code:&myfaq=yes&id_cat2=XX&category=XXXX
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
transit
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Sun Nov 14, 2010 5:40 pm |
|
You were right about the shortlinks I definately jumped the gun there.
However I did have to change the link to reflect catname2 and id_cat2 because I had to change those values since they are also changed in the while loop. I tried with just simply changing over categories to category and it would just display blank spaces where the links would be. The following script below works flawlessly!
Code:
function ShowFaq($id_cat, $categories) {
global $bgcolor2, $sitename, $prefix, $db, $module_name, $admin, $admin_file, $categories;
$categories = htmlentities($categories);
//Below section for category list insertion at the top of every faq
OpenTable();
echo '<center><span class="option">'.$sitename.' '._FAQ2.'</span></center><br /><br />'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr><td bgcolor="'.$bgcolor2.'"><span class="option"><b>'._CATEGORIES.'</b></span></td></tr><tr><td>';
$result3 = $db->sql_query('SELECT id_cat, categories FROM '.$prefix.'_faqcategories '.$querylang);
while ($row2 = $db->sql_fetchrow($result3)) {
$id_cat2 = intval($row2['id_cat']);
$category = stripslashes(check_html($row2['categories'], 'nohtml'));
$catname2 = urlencode($category);
echo'<strong><big>·</big></strong> <a href="modules.php?name='.$module_name.'&myfaq=yes&id_cat='.$id_cat2.'&categories='.$catname2.'">'.$category.'</a>';
echo '<br />';
}
echo '</td></tr></table><br />';
//End of section for category list insertion at the top of every faq
echo '<a name="top"></a><b>'
._CATEGORY.': '.$categories
.'<br /><br /></b>'
.'<table width="100%" cellpadding="4" cellspacing="0" border="0">'
.'<tr bgcolor="'.$bgcolor2.'"><td colspan="2"><font class="option"><b>'
._QUESTION.'</b></font></td></tr><tr><td colspan="2">';
$id_cat = intval($id_cat);
$result = $db->sql_query('SELECT id, id_cat, question, answer FROM '.$prefix.'_faqanswer WHERE id_cat=\''.$id_cat.'\'');
while ($row = $db->sql_fetchrow($result)) {
$id = intval($row['id']);
$id_cat = intval($row['id_cat']);
$question = stripslashes(check_html($row['question'], 'nohtml'));
$answer = stripslashes($row['answer']);
echo'<strong><big>·</big></strong> <a href="#'.$id.'">'.$question.'</a>';
if (is_admin($admin)) {
echo ' [ <a href="'.$admin_file.'.php?op=FaqCatGoEdit&id='.$id.'">'._EDIT.'</a>'
.' | <a class="rn_csrf" href="'.$admin_file.'.php?op=FaqCatGoDel&id='.$id.'&ok=0">'._DELETE.'</a> ]';
}
echo '<br />';
}
echo '</td></tr></table><br />';
}
CloseTable();
|
|
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|