View Single Post
Old 06-16-2004, 07:24 PM   #8 (permalink)
nextGoal100kVisitors
Inactive
 
Join Date: 04-15-04
Location: Out there ...
Posts: 197
iTrader: 0 / 0%
Latest Blog:
None

nextGoal100kVisitors is liked by many
Update

I recently made additional changes in order to make the directory work better for SEO. In specific, I changed two things:

1. URL strings are all in lower case, and they use hyphen "-" instead of underscore "_".

2. I added some code to create better title <title></title> for each page.

Changes made are as follows:

i) pathinfo.php looks like the following now:
[code:1:f2c6351783]
<?php
$GetCategoryId=Array();
$MatchTitle=Array();
$MatchCategory=Array();

$query="SELECT id, name FROM ".DB_PREFIX."categories WHERE parent!='-1' ORDER BY id";
$result=mysql_query($query);
while($row=mysql_fetch_row($result))
{
$count=1;
$currentcat=$row[0];
while($currentcat!="0")
{
$cquery="SELECT id, name, parent FROM ".DB_PREFIX."categories WHERE id='$currentcat'";
$cresult=mysql_query($cquery);
if(mysql_num_rows($cresult)>0)
{
$crow=mysql_fetch_row($cresult);
$parray[0][$count]=$crow[0];
$parray[1][$count]=$crow[1];
$currentcat=$crow[2];
} else
{
$currentcat=0;
}
$count=$count+1;
}
$tree="";
$treeReverse="";
while($count>1)
{
$count=$count-1;
if(($count!="0" && $count!="1")&&isset($parray[1][$count]))
{
$tree.=opmaak($parray[1][$count])."/";
if ($treeReverse == "")
{
$treeReverse=opmaak($parray[1][$count]);
} else
{
$treeReverse=opmaak($parray[1][$count])." - ".$treeReverse;
}
}
}

$urlstring = strtolower(str_replace(" ", "-", $tree.opmaak($row[1])));
$GetCategoryId["/".$urlstring."/"]="".$row[0];
if ($treeReverse == "")
{
$MatchTitle["".$row[0]]=opmaak($row[1]);
} else
{
$MatchTitle["".$row[0]]=opmaak($row[1])." - ".$treeReverse;
}
$MatchCategory["".$row[0]]=$urlstring."/";
}

if ($cat == "0")
{
if (strlen($_SERVER['PATH_INFO']) > 1
&& $_SERVER['PATH_INFO']{strlen($_SERVER['PATH_INFO'] ) - 1} != "/")
{
$cat = $GetCategoryId[$_SERVER['PATH_INFO']."/"];
} else
{
$cat = $GetCategoryId[$_SERVER['PATH_INFO']];
}
if ($cat == "")
{
$cat == "0";
}
}
?>[/code:1:f2c6351783]
This takes care of 1 and also MatchTitle is set up to take care of 2.

ii) In header.php, replace
[code:1:f2c6351783]
$ws->assignGlobal("SITENAME", $config['sitename']);
$ws->assign("STYLEFILE", $config['stylefile']);[/code:1:f2c6351783]
with
[code:1:f2c6351783]
$ws->assignGlobal("SITENAME", $config['sitename']);
$ws->assignGlobal("THISCAT", (int) $cat);
$ws->assignGlobal("THISDIR", $MatchCategory[(int) $cat]);
if ($cat == 0)
{
$ws->assignGlobal("THISTITLE", $config['sitename']);
} else
{
$ws->assignGlobal("THISTITLE", $MatchTitle[(int) $cat]);
}
$ws->assign("STYLEFILE", $config['stylefile']);[/code:1:f2c6351783]
This sets title.

iii) Finally, in templates/header.php, use
[code:1:f2c6351783]
<title>{THISTITLE}</title>[/code:1:f2c6351783]
That's it!

Let me know if you have any question, comment, suggestion and/or concern. I'd appreciate any input on this. Also is anyone interested in having a copy of this entire directory code? Not the original copy, but the modified version, the copy that creates this directory. You do need to change header and footer, but once you do that, you'll have your own search engine friendly search directory. Let me know; I don't know exactly how to provide a copy of code yet, but we'll figure out.
nextGoal100kVisitors is offline   Reply With Quote