Webmaster Forum


Go Back   Webmaster Forum > Marketing Forums > Marketing Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Marketing Forum Marketing, branding and advertising discussions. Online and off-line marketing discussions.

Ezilon Directory   Improve your ranking, submit to directories   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 04-21-2004, 04:47 AM   #1 (permalink)
Inactive
 
Join Date: 04-15-04
Location: Out there ...
Posts: 197
iTrader: 0 / 0%
Latest Blog:
None

nextGoal100kVisitors is liked by many
Creating a user/search engine friendly directory

This is a guide to create a user/search engine friendly directory using Websight http://websight.sourceforge.net/site/; Websight is a directory script written in php. I'd like to present a short tutorial/article on how to make it user/search engine friendly and share with you all today.

I saw many people asking how they can create a user/search engine friendly directory in many forums, so I wrote a guidance a short while ago and posted it in some other forum, but what I suggested initially was not such a great solution. Recently I had chance to review it and present a much better solution; I wanted to start from scratch, so I am posing this short article here. Another reason I am posing this in IMR is that I want to get more feedback from different people.

Though this is an Ok solution, this is probably not the best and greatest; I think the performance can be improved 100% by optimizing the code. So, what I'm hoping to accomplish is

1) If anyone else out there trying to create a user/search engine friendly directory, then they can just look at this short tutorial and do it(Ok, you'd probably have questions, but I will help to the best of my knowledge and ability).

2) I might get some criticism; in specific, criticism with regard to routine efficiency. As I answer those criticism, I can improve my work.

Here we go.

1. First, you create pathinfo.php and place it in the root of the installation directory. The php file looks like this
[code:1:cf80c00e83]
<?php
$GetCategoryId=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="";
while($count>1)
{
$count=$count-1;
if(($count!="0" && $count!="1")&&isset($parray[1][$count]))
{
$tree.=opmaak($parray[1][$count])."/";
}
}

$urlstring = str_replace(" ", "_", $tree.opmaak($row[1]));
$GetCategoryId["/".$urlstring."/"]="".$row[0];
$MatchCategory["".$row[0]]=$urlstring."/";
}

if ($cat == "0")
{
if (strlen($PATH_INFO) > 1
&& $PATH_INFO{strlen($PATH_INFO) - 1} != "/")
{
$cat = $GetCategoryId[$PATH_INFO."/"];
} else
{
$cat = $GetCategoryId[$PATH_INFO];
}
if ($cat == "")
{
$cat == "0";
}
}
?>[/code:1:cf80c00e83]
Note:

You probably need to have
[code:1:cf80c00e83]
$urlstring = str_replace(" ", "_", $tree.opmaak($row[1]));
$GetCategoryId["/".$urlstring."/"]="".$row[0];
$MatchCategory["".$row[0]]=urlencode($urlstring)."/";[/code:1:cf80c00e83]
instead of just
[code:1:cf80c00e83]
$urlstring = str_replace(" ", "_", $tree.opmaak($row[1]));
$GetCategoryId["/".$urlstring."/"]="".$row[0];
$MatchCategory["".$row[0]]=$urlstring."/";[/code:1:cf80c00e83]
for unicode. I haven't tested this extensively, but if you look at the code, you should get the idea.

Basically, this maps url strings to different categories and vice versa. As you can see, this routine maps url strings dynamically, so you do not need to mess with your server so much nor do you need to hard-code url strings.

2. Copy index.php and name it Top(no extension). This(leave a copy of index.php) is not absolutely necessary, BUT this is one quick and dirty way to make everything just work without making too many modifications to replace index.php with Top. Also if you are already running Websight, this is the easiest way to preserve backward compatibility.

3. Include the following line
[code:1:cf80c00e83]
include_once("./pathinfo.php");[/code:1:cf80c00e83]
in confirm.php, privacy.php, search.php, Top, newcat.php, contact.php, index.php, and newlink.php, right after
[code:1:cf80c00e83]
include_once("./includes/functions.php");[/code:1:cf80c00e83]
4. There are functions to check if the file called the function is index.php. Modify them so that both index.php and Top are recognized.

5. ?cat=xxx needs to be replaced with new directory path; you need to do two things to do this.

i) You need to reference $GetCategoryId and $MatchCategory, get new directory paths and save them in an array.

ii) You need to reference the array to get new directory path for each and every ?cat=xxx.

5.2. Paths need to be modified in order to adjust to this change; there are number of ways to fix paths and make the adjustment, but what worked for me was

Create 3 extra variables in websight_config table;
[code:1:cf80c00e83]
basepath
websightroot and
websighttop[/code:1:cf80c00e83]
and set them like the following
[code:1:cf80c00e83]
basepath http://www.yourSite.com
websightroot directory/
websighttop Top/[/code:1:cf80c00e83]
if your root address is http://www.yourSite.com and have your websight installation on http://www.yourSite.com/directory/ directory.

6. Add the following code wherever appropriate depending on your server configuration(.htaccess or vhost.conf).
[code:1:cf80c00e83]
<Files Top>
ForceType application/x-httpd-php
</Files>[/code:1:cf80c00e83]
That's it! Tutorial is rather brief(actually very brief), so there are a couple of things you need to figure out, but you should be able to figure it out. I barely know php, so if you know php just a little, you should be able to figure out details.

Again, I know that this is not the best or the greatest way to do it. A lot of improvements can be made(easily). Let me know and post comments, suggestions, and questions if you have any. Hopefully, we will have a better tutorial here so that people won't be struggling to make a user/search engine friendly directory from now on.

Last Note 1: This is one example of how it's done; Education Website Directory.

Last Note 2: If there is someone who is pretty good at php and wants to rewrite this and publish a more complete article/tutorial, please do so. That would help me as well as other people.
nextGoal100kVisitors is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 04-21-2004, 02:50 PM   #2 (permalink)
Inactive
 
Join Date: 03-08-04
Posts: 508
iTrader: 0 / 0%
Latest Blog:
None

spidersam is liked by many
Good Stuff!
spidersam is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-08-2004, 08:37 PM   #3 (permalink)
Inactive
 
Join Date: 04-15-04
Location: Out there ...
Posts: 197
iTrader: 0 / 0%
Latest Blog:
None

nextGoal100kVisitors is liked by many
I need to some corrections here:

1. Those of you who are using Apache 2 need to use the following code:
[code:1:034989f3c5]
<Files top>
AcceptPathInfo on
SetOutputFilter PHP
SetInputFilter PHP
</Files>[/code:1:034989f3c5]
2. PHP running on Apache 2 appears to have some problem accessing $PATH_INFO directly. It needs to be replaced with $_SERVER['PATH_INFO'].

If anyone has a question, please let me know.
nextGoal100kVisitors is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-09-2004, 06:47 PM   #4 (permalink)
Inactive
 
Join Date: 04-16-04
Location: USA
Posts: 395
iTrader: 0 / 0%
Latest Blog:
None

Blue Tiger is liked by many
Very nice article... very informative
Blue Tiger is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-09-2004, 07:04 PM   #5 (permalink)
Possible Terrorist
 
kwvarga's Avatar
 
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
iTrader: 0 / 0%
Latest Blog:
A+ Certification

kwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web prokwvarga is a highly respected web pro
Send a message via AIM to kwvarga
About the _SERVER stuff it all depends wheter you have the REGISTER_GLOBALS directive set to ON or OFF in the php.ini
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
kwvarga is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-09-2004, 07:21 PM   #6 (permalink)
Inactive
 
Join Date: 04-15-04
Location: Out there ...
Posts: 197
iTrader: 0 / 0%
Latest Blog:
None

nextGoal100kVisitors is liked by many
Quote:
About the _SERVER stuff it all depends whether you have the REGISTER_GLOBALS directive set to ON or OFF in the php.ini
Thanks for the tip. I just moved this directory to a new domain hosted at a new server. The server uses Plesk7 and apparently, its default installation required me to use $_SERVER['PATH_INFO'].
nextGoal100kVisitors is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-10-2004, 11:37 PM   #7 (permalink)
Inactive
 
netsavvy's Avatar
 
Join Date: 06-02-04
Location: India
Posts: 90
iTrader: 0 / 0%
Latest Blog:
None

netsavvy is liked by many
Send a message via Yahoo to netsavvy
Awesome . . . .

Awesome article very informative

Thanks ''nextGoal100kVisitors''
netsavvy is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-16-2004, 07:24 PM   #8 (permalink)
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  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Marketing Forums > Marketing Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
want help in creating user friendly url sudhakar_85dgl SEO Forum 9 05-31-2007 01:03 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 04:16 PM.
© Copyright 2008 V7 Inc