PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 03-21-2004, 09:30 PM   #1
jimfletcher
Green Mole
 
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2
Question How do I create "Site Index" using PHPDig ?

I notice in the /admin section that the script creates a hierarchical tree of the pages on the site.

Is it possible that someone has a method of doing something similar with the Page Title and URL to make a "Site Index" page? Either in a hierarchical tree, or alphabetical something like:
http://www.law.uga.edu/siteindex/index.html
would be great.

Jim
jimfletcher is offline   Reply With Quote
Old 03-22-2004, 11:18 PM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. Perhaps try a query like the following:

SELECT sites.site_url,spider.path,spider.file,spider.first_words FROM sites,spider WHERE sites.site_id = spider.site_id ORDER BY spider.first_words;
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 03-23-2004, 07:58 PM   #3
jimfletcher
Green Mole
 
Join Date: Mar 2004
Location: Atlanta, GA
Posts: 2
Script for Site Map

I wrote this script to create a hierarchy site index from a database that has fields for the URL and the Page Title

What is the best query to get just the URL and the Page Title from the PHPDig database?

PHP Code:
<?
#Hierarchy Site Map
#siteindex.php
#3/23/2004

$myisserver="localhost";
$myisusername="your-mysql-db-username";
$myispassword="your-mysql-db-password";
$myisdb="your-mysql-db-name";

#DATABASE INITIALIZATION
    
$db mysql_connect($myisserver,$myisusername,$myispassword); # Get Connection Settings From Config File
    
mysql_select_db($myisdb,$db); # Get Connection Settings From Config File
    
$sql "SELECT url,pagetitle FROM sometable GROUP BY url ORDER by url";
        
# This script assumes urls stored as something like: /some/directory/structure
    
$result_id mysql_query($sql);
    
$num mysql_num_rows($result_id);
#
print "<ul>"#Start the bullet list
for ($n 0$n<$num$n++) {
    list(
$path_name,$title)=mysql_fetch_row($result_id); #grab the URL and title from the MySQL result
    
$paths explode('/',rawurldecode(rtrim($path_name"/"))); #Trims any trailing slash. Then creates array of URL
    
$num_levels count($paths); #counts directory levels in URL
    
if ($path_name=="") {
        
$num_levels 1#Kluge for the homepage so it shows up on same bullet level as main categories
    
}
    if (
$title!="") { #you can exempt something from the list by not giving it a title
        
$title "<li>" "<a href='".$urlroot $path_name."'>" $title "</a></li>"#set up the link
        
for ($a 1$a<$num_levels$a++) {
            
$title "<ul>" $title "</ul>"#for every additional directory level down this link is, indent again
        
}
        
$title .= "\n"#add a carriage return to keep the output neat
        
print $title#show this bullet
    
}
}
print 
"</ul>"#Close out the bullet list
?>
jimfletcher is offline   Reply With Quote
Old 03-24-2004, 11:27 PM   #4
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Hi. TMTOWTDI, but here's one way to make a sitemap using info in the PhpDig tables.
PHP Code:
<?php

define
('PHPDIG_DB_PREFIX','prefix');
define('PHPDIG_DB_HOST','localhost');
define('PHPDIG_DB_USER','username');
define('PHPDIG_DB_PASS','password');
define('PHPDIG_DB_NAME','database');

$id_connect mysql_connect(PHPDIG_DB_HOST,PHPDIG_DB_USER,PHPDIG_DB_PASS);
if (!
$id_connect) {
    die(
"Unable to connect to database.\n");
}

$db_select mysql_select_db(PHPDIG_DB_NAME,$id_connect);
if (!
$db_select) {
    die(
"Unable to select the database.\n");
}

$query mysql_query("SELECT ".PHPDIG_DB_PREFIX."sites.site_url,".
PHPDIG_DB_PREFIX."spider.path,".PHPDIG_DB_PREFIX."spider.file,".
PHPDIG_DB_PREFIX."spider.first_words FROM ".
PHPDIG_DB_PREFIX."sites,".PHPDIG_DB_PREFIX."spider WHERE ".
PHPDIG_DB_PREFIX."sites.site_id = ".PHPDIG_DB_PREFIX."spider.site_id ".
"ORDER BY ".PHPDIG_DB_PREFIX."sites.site_url,".
PHPDIG_DB_PREFIX."spider.path,".PHPDIG_DB_PREFIX."spider.first_words;");

$num mysql_num_rows($query);
echo 
"<html><body><b>Sitemap</b><br><br>";
list(
$url,$path,$file,$words) = mysql_fetch_row($query);
$one_url $url;
$one_path $path;
echo 
$one_url.$one_path."<ul>";

for (
$i=0$i<$num$i++) {
    if ((
$one_url != $url) || ($one_path != $path)) {
        
$one_url $url;
        
$one_path $path;
        echo 
"</ul>".$one_url.$one_path."<ul>";
    }
    
$full_url $url.$path.$file;
    
$words explode("\n",$words);
    if (
strlen($words[0]) > 20) {
        
$part_words substr($words[0],0,17)."...";
    }
    else {
        
$part_words $words[0];
    }
    echo 
"<li><a href=\"$full_url\">$part_words</a>";
    if (
$i != $num-1) {
        list(
$url,$path,$file,$words) = mysql_fetch_row($query);
    }
}

echo 
"</ul></body></html>";

?>
Remember to remove any "word" wrapping in the above code.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Old 04-16-2004, 03:14 PM   #5
majestique
Green Mole
 
Join Date: Apr 2004
Posts: 16
jimfletcher's code didn't work for me.. but charter's did
majestique is offline   Reply With Quote
Old 07-14-2004, 05:56 AM   #6
zaartix
Orange Mole
 
Join Date: May 2004
Location: russia, samara
Posts: 56
workink perfect for me thanks
zaartix is offline   Reply With Quote
Reply


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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
phpdig not index file if name contain "!" or ' loic@83 Troubleshooting 0 12-14-2007 12:32 PM
shows blank page if "Search All" and "exact phrase", timeout? alokjain9 Troubleshooting 2 03-07-2006 08:08 AM
"I don't want to index your sites!!!" - said PHPDig #ASH How-to Forum 1 04-06-2005 02:57 PM
"search depth" and "links per" features laurentxav How-to Forum 1 01-12-2005 08:27 PM
Removing "Select a site to search" aslan How-to Forum 2 08-25-2004 10:33 PM


All times are GMT -8. The time now is 01:47 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.