ok guys, i can't do this by myself, please help if you can. the issue is: some of the categories in my portal handled by this code are virtual (see $goto) meaning when clicked user goes to a page which through meta tags redirects them to real category. how can i rewrite the code so that when virtual ($goto)
ccategory links clicked then take user user right to category instead of taking them to virual-artificial page and then redirecting them to real page.
let me clarify how and why virtual category. let say i have category marriage and category relationships. under relationship i have subcategory relationship problems, i need it under marriage too, but too avoid duplicate content virtual category is created which goes to a page with virtual category id number then redirects the user to a real category under relationsips main cat. i know this a headacke but i really need it. please help
################################################
This class is set up to ease modification of
the search engine by breaking up the functions
into sections. This class handles all
necessary functions for processing main and
subcategory pages
################################################
Class Process{
################################################
Selects and formats the category linking at
the top of the page as hyperlinked
Expects: Category ID Number
Returns: Catlist as HTML code
################################################
Function FormatCatSel($catstr = "Main"){
################################################
Setup globals to keep from having to pass
variables.
################################################
global $cattable,$conn,$categoryname,$catselid,$catmascatid,$catname,$root_url;
################################################
Select the category from the table, if it's a
goto link, jump to that page.
else, get the information and process the HTML
################################################
$query = "SELECT name, cat_id, mas_cat_id, goto FROM $cattable WHERE cat_id = $catstr";
$result = db_query($query,$conn);
$rowsel = db_fetch_array($result,"");
$goto = $rowsel["goto"];
if ($goto != ""){
print("");
print("<HEAD>");
print("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0; URL=$goto\">");
print("</HEAD>");
print("<BODY>");
print("</BODY>");
print("");
exit;
}
$catname = $rowsel["name"];
$categoryname = $catname;
$catselid = $rowsel["cat_id"];
$catmascatid = $rowsel["mas_cat_id"];
$catsel = " > $catname";
WHILE ($catmascatid > 0):
$query = "SELECT name, cat_id, mas_cat_id FROM $cattable WHERE cat_id = $catmascatid";
$result = db_query($query,$conn);
$rowsel = db_fetch_array($result,$nr);
$catname = $rowsel["name"];
$categid = $rowsel["cat_id"];
$catmascatid = $rowsel["mas_cat_id"];
$openlink = " > <A HREF=\"/c";
$s ="s0.html\">";
$catsel = $openlink . $categid . $s . "$catname</A>" . $catsel;
ENDWHILE;
$catsel = "<A HREF=\"/index.html\">Home</A>" . $catsel;
return $catsel;
}
################################################
Get and format categories in columns for
main pages
Expects: Category ID Number
Returns: Category list as HTML
################################################
Function GetCats($catstr = 0){
################################################
Set up globals to keep from passing a ton of
variables
################################################
global $cattable,$linkcattable, $searchtable,$conn,$numlinks,$rookie,$vet,$tempurl,$numcols;
################################################
Format select statement ordering alphabetically
Bring back number of records.
################################################
$catquery="SELECT * FROM $cattable WHERE mas_cat_id = '$catstr' ORDER BY name";
$catresult = db_query($catquery,$conn);
$catnumber = db_num_rows($catresult);
$catnumber = $catnumber;
################################################
If number of records = 0 then we don't need to
do anything, else we need to format the HTML
################################################
IF ($catnumber > 0) :
$cats = "<TR>";
$flag = 1;
################################################
Once we know we have at least 1 record, we loop
through the recordset until we are finished
retrieving data
################################################
WHILE ($row=db_fetch_array($catresult,"")):
$cat_id = $row["cat_id"];
$goto = $row["goto"];
################################################
Format the select statement to find out how
many links the category has under it.
################################################
$que = "SELECT $linkcattable.lid FROM $linkcattable,$searchtable where $linkcattable.category = '$cat_id' AND $searchtable.priority > -1 AND $searchtable.lid = $linkcattable.lid";
$queresult = db_query($que,$conn);
$numlinks = db_num_rows($queresult);
$numlinks = "$numlinks";
if ($goto != ""){
$numlinks = "Go There";
}
$dbrow = db_fetch_array($queresult,"");
$lid = $dbrow["lid"];
################################################
Format select statement to find out whether
the category contains new or veteran links
and put together the rookie and vet tags
################################################
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew-$timenew2-$timenew3)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie3\">New</sup></small>";
}
else
{
$rookie="";
}
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew-$timenew2)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie2\">Newer</sup></small>";
}
$newque = "SELECT date FROM $searchtable, $linkcattable WHERE ($searchtable.lid = $linkcattable.lid AND $linkcattable.category = '$cat_id' AND date > '" . date("Y-m-d H:i:s", (time()-$timenew)) . "' AND $searchtable.priority > -1)";
$newresult = db_query($newque,$conn);
if (db_num_rows($newresult) > 0)
{
$rookie="<small><sup class=\"rookie\">Newest</sup></small>";
}
################################################
If we are displaying the subcategories as links
then we need to format these now.
otherwise, we display the description
################################################
if ($subcatlink == 1){
$tempdesc = "";
$linkquery = "SELECT name, cat_id from $cattable where mas_cat_id = $cat_id";
$linkresult = db_query($linkquery,$conn);
WHILE ($linkrow = db_fetch_array($linkresult,"")){
$linkcat_id = $linkrow["cat_id"];
$linkcategory = $linkrow["name"];
$tempdesc .= "<A HREF='$root_url/index.php3?catstr=$linkcat_id'>$linkcategory, </A>";
}
$description = $tempdesc;
}
else{
$description = $row["description"];
}
$category = $row["name"];
$templine="";
include ("catlink.php3");
$cats= $cats . $catlinks;
################################################
if we have reached the right number of columns,
end the row and start a new row
################################################
if ($flag == $numcols){
$cats = $cats . "</TR><TR> ";
$flag=1;
}
else{
$flag = $flag + 1;
}
$catlinks = "";
ENDWHILE;
$cats = $cats . "</TR>";
ENDIF;
################################################
Return the HTML formatted categories.
################################################
return $cats;
}
}