Site Sift Listings ~ Site title in detail pages

Discussion in 'Directories' started by terryuk, Jun 26, 2007.

  1. #1
    I'm in the middle of making some stuff for LinksJuice.com including a search function :eek: :p But i wanted to make the detail pages have the website title in the URL like you have probably seen alot of PHPLD directories doing.

    I personally like backlinks from these types of detail pages, so I decided to take a look at what I needed to do.. I noticed site-sift had originally attempted on doing this but made an error in a piece of code so it didn't work!

    The new linksjuice detail pages are looking like this instead of that (now gets redirected to homepage).

    If your a site-sift user, theres a really simple way of doing this which is shown below;

    Open up pages.php and find

    
    <? echo gLink($spages['title'],'detail',$page['id'],$myconn); ?>
    
    Code (markup):
    Change that to;

    
    <? echo gLink($page['title'],'detail',$page['id'],$myconn); ?>
    
    Code (markup):
    Now do the same on spages.php!! There is only one problem now, both the new and old detail page URLs work due to dodge coding. So the only way I could stop the old one from working was to redirect the old ones to the homepage with a 301 header;

    Open your htaccess file, you should have something like;

    
    RewriteRule ^(.*)-(.*)-(.*).html$ index.php?go=$2&id=$3 [L,NC]
    
    Code (markup):
    Now change that to

    
    RewriteRule ^(.*)-(.*)-(.*).html$ index.php?go=$2&id=$3&resource=$1 [L,NC]
    
    Code (markup):
    Now open your index.php and add this to the top;

    
    
    <?php require_once('Connections/myconn.php'); 
    require_once('include/myfunctions.ini.php');
    if($_GET["go"] == "detail"){
    $id = $_GET["id"];
    $resource = $_GET["resource"];
    $query_page = "SELECT * FROM pages WHERE id = \"$id\"";
    $page = mysql_query($query_page, $myconn) or die(mysql_error());
    $row_page = mysql_fetch_assoc($page);
    $keywords = $row_page['title'];
    	$keywords = eregi_replace("[^a-zA-Z0-9_ ]",'',$keywords);	
    	$keywords = str_replace(' ','_',$keywords);	
    	$keywords = eregi_replace("[_]+",'_',$keywords);	
    if(!preg_match("/$keywords/", "$resource")){
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: http://www.YOURDOMAIN.com"); 
    }
    } ?>
    
    Code (markup):
    I think thats everything!!

    I'm just trying to help the good ol' site-sift users out heh, so I will not be hold responsible for any damage caused, and sorry if my codes messy or just plain stupid :D
     
    terryuk, Jun 26, 2007 IP
    onlinedude and Richie_Ni like this.
  2. amitpatel_3001

    amitpatel_3001 Results Follow Patience

    Messages:
    14,074
    Likes Received:
    1,178
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Well done terry :) and good tutorial there in :)
    Amit
     
    amitpatel_3001, Jun 26, 2007 IP
  3. terryuk

    terryuk Notable Member

    Messages:
    3,962
    Likes Received:
    319
    Best Answers:
    0
    Trophy Points:
    255
    #3
    Thanks Amit!

    Oops, I knew I had forgotten something :D

    Open includes/myfunctions.ini.php

    Find

    #gLink Function -- return a href for a <a> tag pending mod rewrite setting

    Then replace the whole gLink function with;

    
    #gLink Function -- return a href for a <a> tag pending mod rewrite setting
    /*string go, string id, mysql connection $mycon*/
    function gLink($keywords,$go,$id,$myconn,$page=false){
    	
    	global $LINK_BASE;
    	if($go == 'detail'){
    	
    		$sql = "select * from settings where id = '1'";
    		$r = mysql_query($sql,$myconn);
    		$settings = mysql_fetch_assoc($r);
    		if($settings['directLink'] == 'No'){
    			$sql = "select url from pages where id = '" . $id . "'";
    			$r = mysql_query($sql,$myconn);
    			$page = mysql_fetch_assoc($r);
    			return $page['url'];
    		}
    	}
    	$keywords = eregi_replace("[^a-zA-Z0-9_ ]",'',$keywords);	
    	$keywords = str_replace(' ','_',$keywords);	
    	$keywords = eregi_replace("[_]+",'_',$keywords);						
    	if($_SESSION['MM_UserGroup'] == 'Admin') {//disable seo urls if loged in as admin
    		$return = 'index.php?go=' . $go . '&id=' . $id;
    		if ($page > '0') {
    			$return .= '&pageNum_pages=' . $page;
    		}
    		return $return;
    	}
    	$sql = "select seoUrl from settings where id = '1'";
    	$results = mysql_query($sql,$myconn) or die(mysql_error());
    	$settings = mysql_fetch_assoc($results);
    	if($settings['seoUrl'] == 'Yes'){
    		if($go == 'detail') {
    			return $keywords . '-' . $go . '-' . $id . '.html';
    		} else {
    			$return = $LINK_BASE . $id . '/' . $keywords . '/';
    			if ($page > '0') {
    				$return .= $page . '/';
    			}
    			return $return;
    		}
    //		return $keywords.'-'.$go.'-'.$id.'.html';
    	} else {
    		$return = $LINK_BASE . 'index.php?go='.$go.'&id='.$id;
    		if ($page > '0') {
    			$return .= '&pageNum_pages=' . $page;
    		}
    		return $return;
    	}
    }//end gLink function
    Code (markup):
     
    terryuk, Jun 26, 2007 IP
    amitpatel_3001 likes this.
  4. smub

    smub Notable Member

    Messages:
    3,443
    Likes Received:
    375
    Best Answers:
    0
    Trophy Points:
    230
    #4
    this is awesome dude .... :)

    now its time for me to get a site-sift site and make a new design hehe
     
    smub, Jun 26, 2007 IP
  5. Richie_Ni

    Richie_Ni Illustrious Member

    Messages:
    10,721
    Likes Received:
    1,175
    Best Answers:
    0
    Trophy Points:
    410
    #5
    Very detailed tutorial.
    Thanks terry!
     
    Richie_Ni, Jun 26, 2007 IP
  6. coolweb

    coolweb Notable Member

    Messages:
    3,884
    Likes Received:
    426
    Best Answers:
    0
    Trophy Points:
    230
    #6
    Great contribution, it's what i was looking for :) Thanks for the detailed tutorial will try on ElegantDirectory soon.
     
    coolweb, Jun 27, 2007 IP