Page 1 of 1
need help excluding files in sitemap generator...
Posted: Mon May 12, 2003 2:43 pm
by bcp1961
I'm trying to exclude files and folder/files from the output of this sitemap generator. This is the code I'm using but it's not working.
Code: Select all
list_dir($root);
$exclude = ("index.html");
ereg_replace("$exlude", " ", "$root");
echo "</table>";
p
I don't know very much about scripting, and I'm obviously missing the boat somewhere...can anyone help!?
Much appreciated! :roll
Posted: Mon May 12, 2003 4:27 pm
by twigletmac
You would have to set the result of the replacing as variable to be able to do anything with it, but there are some questions to be asked:
Code: Select all
/* want does list_dir() do? does it echo something directly or does it return a value? */
list_dir($root);
$exclude = 'index.html'; /* you really don't need parenthesis here it just adds uneccesary gumpf */
$excluded_removed = str_replace($exclude, '', $root); /* quotes are not required around variable names and you should avoid quoting single variables */
/* where do you echo the sitemap information? */
Mac
Re: Help with exclude files
Posted: Mon May 12, 2003 6:52 pm
by bcp1961
I'm trying to edit this sitemap.php script and I don't know php that well so please bear with if I am not explaining this well ( I am trying not to post too much script!)
I believe that list-dir() is the function that prints out the directory listing that is produced by the sitemap.php. The original script portion I included is at the tail end of the script. "list_dir($root); is part of the original script, the $exclude portions are my additions.
This is at the beginning of the script and $root is later referred to as a global:
$root = getcwd();
I actually want to include a list of files to be excluded, will I need to put parentheses or a | between the listing items?
The only reference in this script to an "echo" type of directive is the "list_dir()".
I hope that answers your questions.
Thanks
Bernadette
Posted: Tue May 13, 2003 2:38 am
by twigletmac
I think that if list_dir() is printing the sitemap then you need to be getting rid of the excluded files within it rather than after because once it's been echoed there's nothing you can do to affect it. Perhaps we could see at least some of list_dir()?
Mac
RE: help with exclude files - here's the show_source link..
Posted: Tue May 13, 2003 7:51 am
by bcp1961
I'm not sure what portion of the code to give you. The only reference to the "list_dir()" that I see relating to printing out the sitemap results is what I gave earlier, but at the beginning of the script there is a "list_dir($chdir)" - I don't think it would be related, but I don't really know enough about this to say. The script is less than 139 lines long and I have it up on my show_source file and I've put the link below, I thought that might be an easier way to see what's going on:
http://1prescription-drugs-info.com/show_color.php
and this link is to the sitemap page:
http://1prescription-drugs-info.com/sitemap.php
I changed the code lines as you suggested and moved it directly above the "list_dir($root);" line but it still isn't excluding the file.
I really appreciate your help
Thanks
Bernadette[/url]