22, November 2008

Menu Builder Script - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Menu Builder Script
« previous next »
Pages: [1] Print

Author Topic: Menu Builder Script  (Read 722 times)
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« on: Sep 10, 2006, 11:24:57 AM »

i came across this script but i cant seem to make it work.

Code:
<?php
$x 
function_name();
function 
function_name()
{
    
// ==== Configuration section =========================================
    
$directory_to_read '../content'// current directory where the file is
   // $file_to_save = "../Navigation.php"; // the file where to save results in
   
$file_to_save "Navigation.php"// the file where to save results in
    
    # HTML tempaltes for the links file:
    
$header " <br> <div class='Nav'> <small>\n";
    
$footer " </small></div> <br> ";
    
$template "<a title=\"[TITLE]\" href=\"../content/[FILENAME]\">[TITLE]</a> <br><br> \n";
    
    
// ==== CODE SECTION ===================================================
    
$links = array(); $d dir($directory_to_read); while ($fn $d->read()) if(is_file($fn)) if(eregi("\.php$",$fn)){ $fn ereg_replace("\.php"''strtolower($fn)); if(ereg("_"$fn)) $links[]= $fn; } $d->close();
    
sort($links);
    
$s .= $header;
    foreach(
$links as $k=>$l){
    
$title ucwords(str_replace('_'' '$l));
    
$filename $l.'.php';
      
$t str_replace('[TITLE]'$title$template);
      
$s.= str_replace('[FILENAME]'$filename$t);
    }
    
$s.= $footer;
    
$fp fopen($file_to_save"w+"); fwrite($fp$s); fclose($fp);
}

function_name();

?>


it is supposed to make a menu for the contents of a directory by saving it in a file chmoded to 777. the filename has to be saved like this: This_is_an_example.php and it will show up in the menu as This is an example.

any assistance will be very much appreciated. thanks!
« Last Edit: Sep 10, 2006, 12:39:23 PM by Nikolas »


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #1 on: Sep 10, 2006, 12:48:44 PM »

Do you get any error from the script when you execute it?

if not, add the above line to the top of the script and let us know what is the output :

Code:
<?php
 ini_set
'display_errors');

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #2 on: Sep 10, 2006, 01:45:53 PM »

hi Nik. thnks in advance.

here are the error messages:

Notice: Undefined variable: x in /xhosts/noads/filipinapenpal.noads.biz/Includes/buildmenu.php on line 3

Notice: Undefined variable: s in /xhosts/noads/filipinapenpal.noads.biz/Includes/buildmenu.php on line 19

Notice: Undefined variable: s in /xhosts/noads/filipinapenpal.noads.biz/Includes/buildmenu.php on line 19


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #3 on: Sep 10, 2006, 06:02:27 PM »

Ok, now remove the first line of the script ($x - function_name()Wink

Does it works now?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #4 on: Sep 10, 2006, 07:01:55 PM »

theres still this error:

Notice: Undefined variable: s in /xhosts/noads/filipinapenpal.noads.biz/Includes/buildmenu.php on line 18


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #5 on: Sep 10, 2006, 10:04:14 PM »

That's just a notice. It should not produce any problem

Anyway after

Code:
function function_name()
{

add this :

Code:
$s = '';

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #6 on: Sep 11, 2006, 12:55:08 AM »

no notices already but its still not generating menu links. i checked the content of the Navigation.php file and this is what it saved, just the header and footre but no menu links:

<br>   <div class='Nav'>   <small>
</small></div>   <br>


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #7 on: Sep 11, 2006, 10:26:30 AM »

I think that this snippet is making a menu only for the php files.

Was there any php file in your directory?

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #8 on: Sep 11, 2006, 11:31:18 AM »

they are all php files in the directory.


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #9 on: Sep 11, 2006, 11:34:34 AM »

Then propably that script don't work.

Maybe I should write a tutorial for that job Smiley

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #10 on: Sep 11, 2006, 11:56:40 AM »

probably youre right.

what do you call a php script that automatically makes a menu out of file names in a directory? i will just search for it on the net?


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #11 on: Sep 11, 2006, 11:58:19 AM »

I don't know, but its ok, it is an easy to develop script.

I will do it and post here later or tomorrow.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #12 on: Sep 11, 2006, 12:08:52 PM »

thanks Nik. it will surely make my content-building work a lot easier!


Last blog : Santiago Beach, Cebu, Philippines
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8249
42481 credits
Members referred : 3



« Reply #13 on: Sep 18, 2006, 04:49:42 PM »

I haven't forgot you my friend, here you are Visit through proxy Wink

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Pinoy Webmaster
.com pimp
*****
Gender: Male
Posts: 1126
6048 credits
Members referred : 0


Philippine Beaches


« Reply #14 on: Sep 20, 2006, 04:38:15 AM »

i didnt want to bother you coz i thought you might be sooo busy. i got the job done last week with a script i found on the net.

ill check your tutorial out. maybe its better than the one i found.

i really appreciate it very much...


Last blog : Santiago Beach, Cebu, Philippines
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=4022
Tags : php html tutorials snippets Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: Menu Builder Script
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Nov 22, 2008, 05:13:45 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 37.733
Total Topics: 7.649
Total Members: 4.393
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: 2bi4ll5

42 Guests, 4 Users online :

16 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.