Jump to content

Dynamic Navigation


kr9091

Recommended Posts

Hello, I am trying to create a "dynamic" navigation with image links defined in a .txt file. My question is, how do I insert those values into an array? here is a sample of the .txt file:

 

TOP

ABOUT,ABOUT.PHP,A.GIF,2

LINKS,LINKS.PHP,L.GIF,1

IDM,IDM.PHP,I.GIF,3

Link to comment
Share on other sites

<?php 
$fp = fopen('flat-file-data.txt','r'); 
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;} 
  
while (!feof($fp)) { 
$line = fgets($fp, 1024); //use 2048 if very long lines 
list ($field1, $field2, $field3, $field4, $field5, $field6) = split ('\,', $line); 
echo ' 
<tr> 
<td>'.$field1.'</td> 
<td>'.$field2.'</td> 
<td>'.$field3.'</td> 
<td>'.$field4.'</td> 
<td>'.$field5.'</td> 
<td>'.$field6.'</td> 
</tr>'; 
$fp++; 
} 
  
fclose($fp); 
  
?> 

 

Link to comment
Share on other sites

<?php 
$fp = fopen('flat-file-data.txt','r'); 
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;} 
  
while (!feof($fp)) { 
$line = fgets($fp, 1024); //use 2048 if very long lines 
list ($field1, $field2, $field3, $field4, $field5, $field6) = split ('\,', $line); 
echo ' 
<tr> 
<td>'.$field1.'</td> 
<td>'.$field2.'</td> 
<td>'.$field3.'</td> 
<td>'.$field4.'</td> 
<td>'.$field5.'</td> 
<td>'.$field6.'</td> 
</tr>'; 
$fp++; 
} 
  
fclose($fp); 
  
?> 

 

 

 

Thanks for your quick reply. I tried the code you supplied and subbed in information where necessary. However, I am still having trouble displaying this properly. Perhaps I was a little too unclear of what I am trying to accomplish. Or perhaps I am not using the code provided, correctly. Let me try again:

 

The website has a navigation bar on either the top or the left side. This choice is dynamically controlled. The navigation bar consists of a home button plus three other choices. These 4 links are image links, not text links.

 

There is a configuration file on the server called "navigation.txt" It contains one record with the navigation location, plus several more for each active/inactive navigation choice:

 

TOP

ACTIVE,ABOUT.PHP,ABOUT.GIF,1

ACTIVE,RES.PHP,RESOURCES.GIF,3

ACTIVE,CLASSES.PHP,CLASS.GIF,2

INACTIVE,CTE.PHP,CTE.GIF,4

 

Each page starts with an include statement, which contains a function called do_navigation() This function should dynamically generate the navigation bar based on the contents of the navigation.txt

 

Do_navigation uses file functions to open and read navigation.txt It saves the value of record 1, which controls whether the navbar is on the side or the top. It should also only load the active navigation data into a 3-dimensional array and sort the array by sequence number. It also generates the HTML which lays out the "home" button plus three dynamic choices which then passes this back to the calling program as a string.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.