Support Forums


Go Back   68 Classifieds Forums > Help & Support > Modules / Plugins / Modifications

Notices

 
LinkBack Thread Tools Display Modes
Old 04-24-2008, 06:49 AM   #1
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,023
Rep Power: 27
seymourjames has a spectacular aura about
Default SEO friendly URLs - support in external.php and sitemap

I notice that the sitemap generator and external.php files are generating URLs for the listings like

http://www.mydomain/viewlisting.php?view=27
http://www.mydomain/viewlisting.php?view=28

etc.

I am using this piece of code in the sitemap generator which probably needs modifying.

$sSQL='SELECT * FROM '.PREFIX.'listings ORDER BY id DESC';
$result=$db->query($sSQL);
while ($rs=$result->fetch())
{
echo '<url>
<loc>'.URL.'/viewlisting.php?view='.$rs['id'].'</loc>
<lastmod>2008-04-18</lastmod>
<priority>0.2</priority>
</url>';
echo "\n";
}

However, each of these URLs is being rewritten by the SEO friendly URL module for a user to something more like

http://www.mydomain/listing/27/bla-bla-bla.html
http://www.mydomain/listing/28/bla-bla.html

So using the site as a user is fine. All renders correctly. One gets the SEO friendly URLs but the search engines are also getting the php ones from the external.php file and the sitemap generator.

I wonder whether that creates an ambiguity for the search engines? Two URLs with the same information. Any ideas how to go about getting this to work in both the sitemap generator and external.php to produce SEO friendly URLs. I am sure it is relatively simple change. I have tried twiddling with the seo/mod_user.php file but cannot get it to do what I want. It seems to be something to do with relative and absolute links to the viewlistings pages.
seymourjames is offline   Reply With Quote
Old 04-24-2008, 10:52 AM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,019
Rep Power: 116
Eric Barnes is a jewel in the rough
Default

Here is an updated external.php file that will be available in v4.0.2:
PHP Code:
<?php
/**********************************
* 68 Classifieds
* http://www.68classifieds.com/
*
* All source code & content (c) Copyright 2007, 68 Classifieds
* unless specifically noted otherwise.
***********************************/
require_once('includes/init.php');

    
$type = ( isset($_GET['type']) ) ? $_GET['type'] : 'new';
    
$limit = ( isset($_GET['limit']) ) ? (int)$_GET['limit'] : '15';
    
$where=" WHERE p.expiration > NOW() AND p.display = 'Y'";
    
    switch(
$type)
    {
        case 
"new":
            
$orderby " ORDER BY p.dateadded DESC";
        break;
        case 
"featured":
            
$orderby " ORDER BY p.dateadded DESC";
            
$where .= " AND p.featured='Y'";
        break;
        case 
"top":
            
$orderby " ORDER BY p.hitcount DESC";
        break;
        default:
            
$orderby " ORDER BY p.dateadded DESC";
    }
    
//now setup the search query
    
$sSQL "SELECT p.id, p.owner, p.title, p.featured, p.section, p.shortDescription, p.description, p.price, p.dateadded, p.expiration, p.display, p.pHighlighted, p.pBold, u.username, u.state, u.city, u.country FROM ".PREFIX."listings AS p LEFT JOIN ".PREFIX."users AS u ON p.owner = u.id";
    
    
//sub categories
    
if(isset($_REQUEST['category']))
    {
        if(isset(
$_REQUEST['showchild']) && $_REQUEST['showchild'] == 'Y')
        {
            require_once(
FILESYSTEM_PATH .'includes/classes/kernel/Categories.php');
            
$Categories = new Categories;
            
$arr_childs = array((int)$_REQUEST['category']);
            
$Categories->get_ids($arr_childs);
            
$options['arr_childs']=$arr_childs;
            
$where .= ( empty($options['arr_childs']) ) ? ''" AND p.section IN ("implode(', '$options['arr_childs']) .")";
        }
        else
        {
            
$where .= ( isset($_REQUEST['category']) ) ? ' AND p.section = '.(int)$_REQUEST['category'] : '';
        }
    }
    
    
//any additional where statements
    
$where .= ( isset($_GET['state']) ) ? ' AND u.state = "'.mysql_real_escape_string($_GET['state']).'"' '';
    
$where .= ( isset($_GET['city']) ) ? ' AND u.city = "'.mysql_real_escape_string($_GET['city']).'"' '';
    
$where .= ( isset($_GET['country']) ) ? ' AND u.country = "'.mysql_real_escape_string($_GET['country']).'"' '';
    
$where .= ( isset($_GET['owner']) ) ? ' AND p.owner = '.(int)$_GET['owner'] : '';
    
    if (isset(
$_REQUEST['searchtext'])&& $_REQUEST['searchtext']<>"")
    {
        
$searchtext=trim(mysql_real_escape_string($_REQUEST['searchtext']));
        
$where .= " AND (p.title LIKE '%".$searchtext."%' OR p.description LIKE '%".$searchtext."%')";
    }
    
//search price//
    
$minprice=(int)trim(@$_REQUEST['minprice']);
    
$maxprice=(int)trim(@$_REQUEST['maxprice']);
    if(
$minprice == "")
        
$minprice=0;
    if(
$maxprice == "")
        
$maxprice=9999999;
    
$where .= " AND p.price BETWEEN "$minprice ." AND "$maxprice;

    
$sSQL $sSQL $where $orderby ." LIMIT "$limit."";

    
$ads = array();
    
$result $db->query($sSQL);
    while (
$rs=$result->fetch()) 
    { 
        
$ads[] = $rs;
    }
    
    
// set XML type and nocache headers
    
header('Content-Type: text/xml');
    
header('Expires: ' gmdate('D, d M Y H:i:s') . ' GMT');
    
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    
header('Pragma: public');
    
    
// print out the page header
    
echo '<?xml version="1.0" encoding="iso-8859-1"?>' "\r\n";
    echo 
'<rss version="2.0">' "\r\n";
    echo 
"<channel>\r\n";
    echo 
"\t<title>" htmlspecialchars($title) . "</title>\r\n";
    echo 
"\t<link>".URL."</link>\r\n";
    echo 
"\t<description>" htmlspecialchars($Core->settings['description']). "</description>\r\n";
    echo 
"\t<language>en</language>\r\n";
    echo 
"\t<generator>68 Classifieds</generator>\r\n";
    echo 
"\t<lastBuildDate>" gmdate('D, d M Y H:i:s') . " GMT</lastBuildDate>\r\n";
    echo 
"\t<pubDate>" gmdate('D, d M Y H:i:s') . " GMT</pubDate>\r\n";
    
    
// list returned threads
    
if (!empty($ads))
    {
        foreach (
$ads as $listing)
        {
            
//item info
            
if($listing['price'] == 0)
            {
                
$price '';
            }
            else
            {
                
$price FormatCurrency($listing['price']);
            }
            
            if(
$price == '')
            {
                
$seperator "";
            }
            else
            {
                
$seperator ' - ';
            }
            
            echo 
"\t\t".'<item>'."\r\n";
            echo 
"\t\t\t".'<title>'htmlspecialchars($listing['title']) . $seperator $price .'</title>'."\r\n";
            if(
defined('SEO'))
            {
                
$listing_title=$listing['title'];
                
$listing_title=str_replace(' ''_'$listing_title);
                
$listing_title=preg_replace('/\W/e'''$listing_title);
                if(
SEO_STRING == 'dash') {
                    
$listing_title=str_replace('_''-'$listing_title);
                }
                
$link=URL ."/listing/".$listing['id']."/".$listing_title.".html";    
            }
            else
            {
                
$link=URL ."/viewlisting.php?view=".$listing['id'];
            }    
            echo 
"\t\t\t".'<guid>'.$link .'</guid>'."\r\n";
            echo 
"\t\t\t"."<link>"$link ."</link>"."\r\n";
                    
            
//get images
            
$isSQL sprintf("SELECT pid,image FROM ".PREFIX."prodimages WHERE pid = %s ORDER BY rank ASC LIMIT 1"$listing['id']);
            
$iresult $db->query($isSQL);
            
$irs=$iresult->fetch();
            if(
$iresult->size() == 1)
            {
               
$imDescription "<a href="$link ."><img src='"URL "/thumbs/small_" $irs['image'] . "' align='left' style='margin: 0 5px 5px 0;' border='0'  /></a>".$listing['description'].'<br clear="all" />';
            }
            else
            {
                
$imDescription "<a href="$link ."><img src='"URL ."/images/nophoto.gif' ' align='left'  style='margin: 0 5px 5px 0;' border='0'  /></a>".$listing['description'].'<br clear="all" />';
            } 
            echo 
"\t\t\t""<description>"htmlspecialchars($imDescription) . "</description>"."\r\n";
            
            
//close the item
            
echo "\t\t".'</item>'."\r\n";
        }
    }
    
    
//close the feed
    
echo "</channel>\r\n";
    echo 
"</rss>";
?>
__________________
Eric Barnes
68 Classifieds Developer
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-24-2008, 12:58 PM   #3
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,023
Rep Power: 27
seymourjames has a spectacular aura about
Default Beta it

Thanks. You are a super chappy. I will beta it for you. I think several people will want to do this if they are spreading their feed.
seymourjames is offline   Reply With Quote
Old 04-24-2008, 01:21 PM   #4
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,023
Rep Power: 27
seymourjames has a spectacular aura about
Default external.php

Well we all look forward to 4.02.

The code works well for me. All the links are SEO friendly. Mr G eat your heart out, Suzkaw is on his way.

I have to say this to the readers. I have only had 68C a few weeks but what great support they offer. I could not have asked for more. Sometimes you just fall upon the right team.
seymourjames is offline   Reply With Quote
Old 06-01-2008, 03:54 AM   #5
Senior Member
 
Join Date: Jun 2007
Posts: 110
Rep Power: 11
crystal is on a distinguished road
Default SEO & Sitemap

I have the SEO mod added on my site, and I just added the sitemap mod. The SEO mod is working great, and my external.php file has the correct SEO links. My sitemap is displaying all of the php links like mysite.com/category.php?cat=forsale. I am using the updated external.php but that doesn't seem to affect the sitemap. How do I get the sitemap to work correctly with the SEO mod?

Also I noticed I don't have any of my pages (relating to pages.php) listed on the sitemap, it is only categories and listings. I'm not sure I understand the structure of the sitemap, and advice is appreciated.

Thank you!
__________________
Crystal
v4.0.8 Dev
crystal is offline   Reply With Quote
Old 06-01-2008, 06:41 AM   #6
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,023
Rep Power: 27
seymourjames has a spectacular aura about
Default

I cannot help you on your question (except I noticed the sitemap module does this so I do not use it). I want my site as far as google is concerned to contain only urls with html extensions. I think site maps are getting overated to be frank. Over the last two yeas I have seen little results from doing sitemaps for google. Time can be better spent on optimising the principle pages of your site.

Do you have problems with pagination and the SEO module. I still cannot get it to render seo friendly urls for category pages where there are multiple pages of listings and one can change the price order for example.

Last edited by seymourjames; 06-01-2008 at 06:50 AM. Reason: forgot to copy up the external.php code given in this thread when upgrading to 4.03
seymourjames is offline   Reply With Quote
Old 06-01-2008, 10:07 PM   #7
Senior Member
 
Join Date: Jun 2007
Posts: 110
Rep Power: 11
crystal is on a distinguished road
Default

Quote:
Originally Posted by seymourjames View Post
Do you have problems with pagination and the SEO module. I still cannot get it to render seo friendly urls for category pages where there are multiple pages of listings and one can change the price order for example.
I have not looked at the pagination yet, as I've already disabled my SEO mod until I get support. My site errors out (goes to 404 page) when any heading is clicked to sort by in showlistings. I just launched and got my first members, with my first round of support emails to go with it. They have pointed out quite a few errors that need to be delt with.
__________________
Crystal
v4.0.8 Dev
crystal is offline   Reply With Quote
Old 06-02-2008, 03:50 PM   #8
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,023
Rep Power: 27
seymourjames has a spectacular aura about
Default

What is the url of your site.
seymourjames is offline   Reply With Quote

Bookmarks

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

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



All times are GMT -4. The time now is 10:35 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0