Click to See Complete Forum and Search --> : getting a number for folder level


TinaBanana
03-09-2007, 01:07 PM
im trying to do some breadcrumbs for my site.

i want an html file in each folder that contains the name and link of the level i am on.

right now the only way of displaying them is to do something like this
<!--#include virtual="../../breadcrumb.html" -->
<!--#include virtual="../breadcrumb.html" -->
<!--#include virtual="breadcrumb.html" -->

but if i ever move this file 5 folders deep, it wont work anymore.

is there a script i can write that will count how many levels deep i am and then can repeat some code similar to above according to how deep the file is.

can anyone write something like that?

TinaBanana
03-09-2007, 01:18 PM
or rather

<?php include("breadcrumb.html"); ?>
<?php include("../breadcrumb.html"); ?>
<?php include("../../breadcrumb.html"); ?>

bokeh
03-09-2007, 02:05 PM
Here's one possible way:$exp = array('/[^\/]/', '/^/', '/(?=(?<=\/)\/)/');
$rep = array('', '.', '..');
$path = preg_replace($exp, $rep, $_SERVER['PHP_SELF']);

include($path . 'breadcrumb.html');

TinaBanana
03-09-2007, 02:11 PM
cool, its pretty much working cept i need to substract a few ../ about 3 of them.

its spitting this out Warning: include(./../../../breadcrumb.html)
when it should be ../breadcrumb.html


how would i do that?

bokeh
03-09-2007, 02:22 PM
Well that's returning the path relative to document root which is what I thought you wanted. Easiest way would be put your file at document root. Else you are going to need to explain better.

TinaBanana
03-09-2007, 02:27 PM
well you are right that this would work fine on our real site where the root of the site is our actual home.

but on this testing server im nested about 3 folders deeper then i normally would. id like to show that this code works....

is there an extra line of code i could add that would result in removing a set amount of those ../

bokeh
03-09-2007, 02:40 PM
Why don't you configure your test server to work properly.

TinaBanana
03-09-2007, 03:06 PM
because this is the governement my friend! its not that easy!
you work with what they give ya!

and actually im not sure if this would work with my live site either...
my index page is not in the root of the server....its inside an htdocs folder etc.

if we could just somehow substract from the results then it could work regarless of how screwed up the levels are.

also the link starts off with a single ./ is that on purpose?

i really hope its possible to do this. thx for your time so far

TinaBanana
03-09-2007, 03:12 PM
or can we tell it where to start counting.
for example tell it to start counting in htdocs?

bokeh
03-09-2007, 04:00 PM
If breadcrumb is in htdocs the following would work:$path = preg_replace('/(.*\/htdocs\/).*/', '$1', $_SERVER['SCRIPT_FILENAME']);
include($path . 'breadcrumb.html');Or are you saying you want to use it ase the reference?

Also "./" means the current directory.

NightShift58
03-09-2007, 04:15 PM
Why not consider set_include_path()?

EDIT: Better function for government servers...

bokeh
03-09-2007, 04:23 PM
Why not consider set_include_path()?

EDIT: Better function for government servers...You would need access to the server for that.

I'm trying to think of a dynamic solution but as always with relatives you need a reference to work from.

NightShift58
03-09-2007, 05:05 PM
You would need access to the server for that.

I'm trying to think of a dynamic solution but as always with relatives you need a reference to work from.
Sets the include_path configuration option for the duration of the scriptIt shouldn't need access to anything, being a PHP_INI_ALL "changeable".

bokeh
03-10-2007, 04:03 AM
It shouldn't need access to anything, being a PHP_INI_ALL "changeable".That defeats the whole point of being dynamic. Something is needed that will work on both servers and that doesn't require 500 files to be edited before being uploaded to the public server.

Here's what I would do: We want the test server to perform I dentically to the public server... so we want the "fake" root directory on the test server to mimic the root directory on the public server.

Assuming apache you could put the following two files in the "fake" root directory:

.htaccessphp_value auto_prepend_file prepend.phpprepend.php<?php

$_SERVER['DOCUMENT_ROOT'] .= substr(preg_replace('#/[^/]+$#', '', str_replace('\\','/', __FILE__)), strlen($_SERVER['DOCUMENT_ROOT']));

?>Now we can use $_SERVER['DOCUMENT_ROOT'] as the reference AND no modification will be needed when the files are placed on the public server.

NightShift58
03-10-2007, 12:00 PM
because this is the governement my friend! its not that easy!
you work with what they give ya!I understood:

"Test Server" <> "Public Server"

however:

"Test Server" == "Govt Server"

TinaBanana
03-10-2007, 08:45 PM
this looks real promising, a fake root document, i like that! good idea.
ill try it on monday and let you know how it works out.

TinaBanana
03-12-2007, 01:39 PM
i want to use htdocs as a reference. i want to make htdocs my root (web route) as opose to usr (server root). by doing this it would put the proper amount of ../

once i can get this working ill play with the htaccess.

i tried a few variation of the scripts you provided me at first, and tried to include htdocs in there but i just dont know enough about php.

bokeh
03-13-2007, 02:11 PM
i want to make htdocs my root (web route) as opose to usr (server root).Can you describe your directory structure? By the way this is an Apache server isn't it.? Also are you using a proper domain name on the test server?

TinaBanana
03-13-2007, 02:22 PM
yes its apache.

url for dev (sub1 and sub2 are extra nested folders on dev)

http://web.domain.com/sub1/sub2/sub3/sub4/index-eng.php

url live

http://www.domain.com/sub3/sub4/index-eng.php

current error on dev (cause it goes too deep)

Warning: include(./../../../../breadcrumb.html) [function.include]: failed to open stream: No such file or directory in /usr/local/apache/htdocs/sub1/sub2/sub3/sub4/index2-eng.php on line 112

Warning: include() [function.include]: Failed opening './../../../../breadcrumb.html' for inclusion (include_path='.:/usr/local/apache2/php ; ; Windows: \path1') in /usr/local/apache/htdocs/sub1/sub2/sub3/sub4/index2-eng.php on line 112

bokeh
03-13-2007, 02:40 PM
This is a bit crap really but I don't have the time to think about it right now:<?php

$exp = array('/[^\/]/', '/^/', '/(?=(?<=\/)\/)/');
$rep = array('', '.', '..');
$path = preg_replace($exp, $rep, $_SERVER['PHP_SELF']);

# modify the following to the test server domain
if('web.domain.com' === $_SERVER['HTTP_HOST'])
{
$path = substr($path, 0, strlen($path)-6);
}

include($path . 'breadcrumb.html');

?>

bokeh
03-13-2007, 02:44 PM
Do all these files share a common include?

TinaBanana
03-13-2007, 02:49 PM
yes the top-left nav and footer are includes.

the code you provided spits out the home and no errors....but it doesnt show the 2 other levels that im in.

it should show home > sub3 > sub4

bokeh
03-13-2007, 03:05 PM
You're making me think too hard. Can you post the real output rather than an enterpretation of it because I don't understand what you are telling me. This should be so simple to sort out but it is very difficult because I don't have all the fact at my fingertips.

TinaBanana
03-13-2007, 03:12 PM
url for dev

http://web.domain.com/working/temp/media/nr/index-eng.php

url live

http://www.domain.com/media/nr/index-eng.php

current breadcrumb output is

home

its only including the first breadcrumb.html

but since i am 2 folders deep, the breadcrumb output should be

home > media > new releases

it needs to add/substract from the ../../ depending on how deep it is.

im sorry this is so complicated

bokeh
03-13-2007, 03:52 PM
yes the top-left nav and footer are includes.

the code you provided spits out the home and no errors....but it doesnt show the 2 other levels that im in.

it should show home > sub3 > sub4Isn't that the behaviour you want when it is on the public server? It must be correct because it is finding the file. If the output is wrong it must be a problem with the include.

NightShift58
03-13-2007, 04:18 PM
[quote=bokeh]<?php
$_SERVER['DOCUMENT_ROOT'] .= substr(preg_replace('#/[^/]+$#', '', str_replace('\\','/', __FILE__)), strlen($_SERVER['DOCUMENT_ROOT']));
?> [/php]could this be happening because prepend.php is referencing __FILE__ instead of PHP_SELF?

EDIT: Forget it. Realized what I wrote as I was clicking submit.

bokeh
03-13-2007, 05:19 PM
Well the thread is taking a lot of twists and turns and I'm working so I'm not paying much attention but I intended the code in post #20 to be used as a stand alone.

TinaBanana
03-14-2007, 08:22 AM
Isn't that the behaviour you want when it is on the public server? It must be correct because it is finding the file. If the output is wrong it must be a problem with the include.

well i dont want it to just spit out 'home' by itself on every page.
it needs to display the other levels as well.
home > media > new releases

bokeh
03-14-2007, 01:19 PM
I have re-read the question now and I think the following should work fine:<?php

$file = 'breadcrumb.html';

$exp = array('/[^\/]/', '/^/', '/(?=(?<=\/)\/)/');
$rep = array('', '.', '..');
$path = preg_replace($exp, $rep, $_SERVER['PHP_SELF']);

$trail = '';

while($path)
{
if(is_file($path . $file))
{
ob_start();
require($path . $file);
if($temp = ob_get_clean() and $trail)
{
$trail .= ' > ';
}
$trail .= $temp;
}
$path = substr($path, 0, max(0, strlen($path)-3));
}

echo $trail;

?>Recommended contents of breadcrumb.html is as follows:

Static:<?php

$title = 'Directory Name';

echo "<a href='$path'>$title</a>";

?>Or dynamic:<?php

$title = strtoupper(preg_replace('#^.*(\\\\|/)([^\1]+)\1.*$#', '$2', __FILE__));

echo "<a href='$path'>$title</a>";

?>Using either of these two in the breadcrumb file means the breadcrumb paths will be correct whichever server or directory structure they are located in.

TinaBanana
03-14-2007, 06:12 PM
that worked BEAUTIFULY! exactly what i wanted.
thx so much.

i edited it a little so i can use the same page for english and french.

you should seriously post this on hotscripts or some site, im sure there are plenty of other ppl who would find this useful.

bokeh
03-14-2007, 06:34 PM
You're welcome! About the $title thingy I'm not really sure what you mean. You'll need to explain in more detail.

TinaBanana
03-15-2007, 08:56 AM
we have english and french pages for the same content. i edited the script so i can use one breadcrumb file for both pages. can you let me know if there is anything horribly wrong with this code. until 2 weeks ago i couldnt understand php at all so forgive me if its bad lol


$titleEN = 'Media Room';
$titleFR = 'Salle des médias';

//$lang is from $_SERVER['PHP_SELF'] from the other page
if (preg_match ("!-eng.php!", "$lang")) {
$en = "<a href=\"$path" . "index-eng.php\">$titleEN</a>";
echo $en;
} else {
$fr = "<a href=\"$path" . "index-fra.php\">$titleFR</a>";
echo $fr;
}



Also i was wondering if it would be possible to have my menu generated from all my $titleEn and $titleFR.

A script that would look for all the sub folders one level deeper then where it is and return all the $title from the breadcrumb.html

For example with a layout like this


About Us

Media
New releases
2007
archives
Advisories
Videos

Contact Us
Main office
Region



Media would have a menu with the $title from the breadcrumb.html file from New releases, Advisory and Video.

New release would have a menu with 2007 and archives

Contact Us would have a menu Main office and Region.

While About Us would have no menu because there is no sub folder.

This wasnt my original idea, but it seems like such a shame to hand code those menus when all the data is right there.

But if its too complicated forget about it.

bokeh
03-15-2007, 09:37 AM
<?php

$file = 'breadcrumb.html';

$paths = array();
$output = array();

foreach(glob('./*/'.$file) as $v)
{
$paths[] = preg_replace('/'.preg_quote($file, '/').'$/','',$v);
}

foreach($paths as $path)
{
ob_start();
require($path . $file);
$output[] = ob_get_clean();
}

// now do something with it
echo implode('<br>', $output);

?>

TinaBanana
03-15-2007, 10:31 AM
that worked GREAT thx again.

how do you get not empty

if (empty($output))

bokeh
03-15-2007, 01:00 PM
Well since the array is already in existance you could do any one of the following:

if($output)

if(count($output))

if(!(empty($output)))

if(!empty($output))

TinaBanana
03-15-2007, 02:17 PM
oh that was way too easy lol sorry.

is there a way to call a variable in a certain include file.....
something that would do this....(insert proper expresssion between # #)

<?php echo $title #from the file# '../breadcrumb.html' ?>

bokeh
03-15-2007, 02:29 PM
Can you be more descriptive about what you are attempting and the desire outcome.

TinaBanana
03-15-2007, 02:44 PM
ok lets take my structure from before


About Us

Media
New releases
2007
archives
Advisories
Videos

Contact Us
Main office
Region


lets say i am in a file in the 2007 folder and i want to output $title that is in the breadcrumb.html 2 levels deper (the media breadcrumb.html)

bokeh
03-16-2007, 03:08 AM
$titleEN = 'Media Room';
$titleFR = 'Salle des médias';

//$lang is from $_SERVER['PHP_SELF'] from the other page
if (preg_match ("!-eng.php!", "$lang")) {
$en = "<a href=\"$path" . "index-eng.php\">$titleEN</a>";
echo $en;
} else {
$fr = "<a href=\"$path" . "index-fra.php\">$titleFR</a>";
echo $fr;
}

Well first your file doesn't contain a $title variable so you would need to create one. This is where your modification has fallen on it's face; what you have done is created multiple variables. What you should do is always bring the focus back to one variable so no further conditional statements are required in subsequent code to try to work out what you named the variables you now wish to access.<?php

$title = 'Media Room';
$titleFR = 'Salle des médias';
if (preg_match ("!-fra.php!", "$lang"))
{
echo "<a href='{$path}index-fra.php'>".($title = $titleFR)."</a>";
}
else
{
echo "<a href='{$path}index-eng.php'>$title</a>";
}

?>Now to get that variable available to your main script you could do this:ob_start();
require($path . $file);
ob_get_clean();

//do something with it...
echo $title;

bokeh
03-16-2007, 04:07 AM
Mejor!

<?php

$language = preg_replace('#^.*?(?:-([a-z]{3})|)(?=\.php$).*?$#', '$1', $_SERVER['PHP_SELF']);

$title = $language === 'fra'?'Salle des médias':'Media Room';

echo "<a href='{$path}index-$language.php'>$title</a>";

?>

TinaBanana
03-16-2007, 09:34 AM
thx for rewriting that code so its more efficient, it would have worked by calling the $title in its language on each page, but with having the same variable its even easier.

im working on the last peice of a puzzle then ill have my site done.

the ob start worked great, thx.

TinaBanana
03-16-2007, 11:43 AM
I give up, can you pls help with this one last thing.

in the code you gave me in post #33 for the menu. i had it working fine until i realized that i need a different behavior for the last item.


Media
New releases
2007
archives


here is the thing, i made a duplicate of the breadcrumb script and removed the section where it adds the >

then i added the script menu at the bottom. and added this to the output

// now do something with it
if ($output) {
echo '<ul>';
echo implode('', $output);
echo '</ul>';
}

so if i am in the 2007 folder i get this in the left menu

<ul>
<li>Home</li> (the <li></li> comes from the breadcrumb.html file)
<li>Media</li>
<li>News releases</li>
<li>2007</li>
</ul>

but i need to get this instead (this is the same display that i get when i am in the news releases section)


<ul>
<li>Home</li>
<li>Media</li>
<li>News releases</li>
<ul>
<li>2007</li>
</ul>
</ul>

i wonder if you can understand this, i tried to explain best i can.
basicly what needs to happen, is when there is no subfolder, the last breadcrumb item should not display as a breadcrumb, but rather as part of the menu.

bokeh
03-16-2007, 01:07 PM
I don't suppose you could PM me a URL

TinaBanana
03-16-2007, 02:39 PM
no its on a darn intranet

bokeh
03-17-2007, 08:45 AM
Ok first a slight mod to the breadcrumb file to save running the regex repetatively for no reason in every file:<?php

if(empty($language))
{
$language = preg_replace('#^.*?(?:-([a-z]{3})|)(?=\.php$).*?$#', '$1', $_SERVER['PHP_SELF']);
}

$title = $language === 'fra'?'Salle des médias':'Media Room';

echo "<a href='{$path}index-$language.php'>$title</a>";

?>So you do realise the breadcrumb trail and the menu system are two completely unrelated things (although we could use the same files). Let me think and I will post something a menu system that can be built using the current breadcrumb files formated as a nested unordered list.

bokeh
03-17-2007, 07:19 PM
$file = 'breadcrumb.html';

echo MakeSubMenu('./', $file);

function MakeSubMenu($dir, $file)
{
static $indent = '';
if ($handle = opendir($dir))
{
$output = '';
while (false !== ($item = readdir($handle)))
{
if(!preg_match('/^\./', $item))
{
if (is_dir($path = $dir.$item.'/'))
{
if(file_exists($path . $file))
{
$indent .= ' ';
ob_start();
require($path . $file);
$output .= $indent."<li>\n";
$indent .= ' ';
$output .= $indent.ob_get_clean()."\n";
$output .= MakeSubMenu($path, $file);
$indent = substr($indent, 0, strlen($indent)-1);
$output .= "$indent</li>\n";
$indent = substr($indent, 0, strlen($indent)-1);
}
}
}
}
closedir($handle);
return $output ? "$indent<ul>\n$output$indent</ul>\n" : null ;
}
}

NightShift58
03-17-2007, 11:58 PM
Love it... No eval()...

bokeh
03-18-2007, 06:41 AM
Just to show it actually works this is what it produces:<ul>
<li>
<a href='./myhomewebserver/'>MyHomeWebServer</a>
<ul>
<li>
<a href='./myhomewebserver/web/'>Web</a>
<ul>
<li>
<a href='./myhomewebserver/web/cbt/'>CBT</a>
<ul>
<li>
<a href='./myhomewebserver/web/cbt/logos/'>Logos</a>
</li>
</ul>
</li>
<li>
<a href='./myhomewebserver/web/rollover/'>Rollover</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>

bokeh
03-18-2007, 06:50 AM
Love it... No eval()...Did you think of a way to have a variable number of for loops without the eval function?

NightShift58
03-18-2007, 09:28 PM
I had posted that you would want to use recursion, as you did in this case.

In the other case, you would have to use a static variable to maintain control over the recursive iterations. But let me look for it.

NightShift58
03-18-2007, 09:49 PM
I looked at it again and it's hard for me to give you a coded alternative because the function lacks any kind of description/documentation and the code is extremely obfuscated.

However, it's very clear and obvious that everything you're doing between the for (...) { and } is pure and simple recursion. You're using the FOR loop to recursively build a character string which you later eval().

It would be more efficient, easier to code - AND understand - if proper - rather than simulated - recursion were used.

NightShift58
03-19-2007, 01:46 AM
Dont' know which you'll be reading, so here it is once more.

As I try to decipher the function, I did come across some some redundancies in the current code, which with a $max_len of 4 will cost you close to .8 seconds. Here's a version with some of the redundant code removed/fixed:function BruteForceMD5($md5, $charset, $max_len) {
$cnt = strlen($charset);
FOR ($x=0; $x < $max_len; ++$x) :
@$Dopey .= 'for($l'.$x.'=0;$l'.$x.'<'.$cnt.';++$l'.$x.')';
@$Grumpy.=($x?'.':'').'$charset[$l'.$x.']';
ENDFOR;
return eval($Dopey.'if($md5===md5($Doc='.$Grumpy.'))return$Doc;return false;');
}Basically, there's no need for $Bashful's omnipresence nor for $Sleepy existence.

TinaBanana
03-19-2007, 08:42 AM
bokeh, the code you provided doesnt quite give me the output i want.


about
media
new releases
minister


when i am in about, the output is

<ul>
<ul>
<li>
<a href='./media/index-eng.php'>Media</a>
<ul>
<li>
<a href='./media/nr-cp/index-eng.php'>News Releases</a>
</li>
</ul>
</li>
<li>
<li><a href='./ministr/index-eng.php'>Minister</a></li>
</li>
</ul>
</ul>



and the output i would want when in about is

home
about
media


when in new releases


home
about
media
new releases

bokeh
03-19-2007, 09:05 AM
the output i would want when in about is

home
about
media


when in new releases


home
about
media
new releases
You can't have your cake and eat it. Whichever way you do it the pattern must be the same in both cases. My function above was to recurse down through all descendant directories until no breadcrumb file was found. What you are now suggesting (it would seem) is you want the trail of the superior directories (justified fully left) followed by a list of the child (not descendant) directories with a bit of left padding. Is that correct?

TinaBanana
03-20-2007, 08:40 AM
you want the trail of the superior directories (justified fully left)
yes


followed by a list of the child (not descendant) directories with a bit of left padding. Is that correct?


as long as there are still sub folders, the trail and parents should display on the left, and the sub folders indented in a <ul>. only the subfolders of the section you are in should show.

once there are no sub folders, the trail should display, but the parent should display as the last item on the left, and the list of subfolders you are currently in should be indented in the extra <ul>

so as an extra example. if new releases had no sub folders it would display like this.


home
about
media
new releases


but if it did have a sub folder it would be like this


home
about
media
new releases
2007
2006

bokeh
03-20-2007, 01:53 PM
I'm bored with this tread now so this is my last post.function TrailMenu($file = 'breadcrumb.html')
{
$ClassName1 = 'superior';
$ClassName2 = 'subordinate';

$rtn = array();
$temp = array();

foreach(glob('./*', GLOB_ONLYDIR) as $path)
{
if(is_file($path .'/'. $file))
{
ob_start();
require($path .'/'. $file);
$temp[] = " <li class='$ClassName2'>\n ".ob_get_clean()."\n </li>\n";
}
}

$exp = array('/[^\/]/', '/^/', '/(?=(?<=\/)\/)/');
$rep = array('', '.', '..');
$path = preg_replace($exp, $rep, $_SERVER['PHP_SELF']);

while($path)
{
if(is_file($path . $file))
{
ob_start();
require($path . $file);
$rtn[] = " <li class='".
((!$temp and './' === $path)?$ClassName2:$ClassName1).
"'>\n ".ob_get_clean()."\n </li>\n";
}
$path = substr($path, 0, max(0, strlen($path)-3));
}

if(count($rtn = array_merge($rtn, $temp)))
{
$rtn = "<ul class='trail'>\n".implode($rtn)."</ul>\n";
}
return $rtn;
}Put the following in your file where you want the menu to appear:echo TrailMenu();That produces something like this:<ul class='trail'>
<li class='superior'>
<a href='./../../'>WWW</a>
</li>
<li class='superior'>
<a href='./../'>MyHomeWebServer</a>
</li>
<li class='superior'>
<a href='./'>Web</a>
</li>
<li class='subordinate'>
<a href='./cbt'>CBT</a>
</li>
<li class='subordinate'>
<a href='./rollover'>ROLLOVER</a>
</li>
</ul>To make it look how you want just add something like the following to your stylesheet (no need for nested lists):ul.trail{list-style:none}
ul.trail li.superior{padding-left:0}
ul.trail li.subordinate{padding-left:1em}

TinaBanana
03-21-2007, 09:09 AM
thx for all your help, i appreciate it.

TinaBanana
05-09-2007, 08:27 AM
im hoping that someone can help me with this last peice of the puzzle.

i have (somehow) edited the script to work as i want it too, but it has just one small little problem.

once i am down to the last level of menus, i get an extra folder in there.
i cannot edit the breadcrumb.html too much because i have another file calling it, but the problem seems to be related to the $path called in the breadcrumb.html file

for someone looking at this with new eyes, each folder has an index-eng.php file and a breadcrumb.html file.

breadcrumb.html


<?php
$language = preg_replace('#^.*?(?:-([a-z]{3})|)(?=.php).*?#', '$1', $_SERVER['PHP_SELF']);
$title = $language === 'fra'?'Aliments et nutrition':'Food and Nutrition';
echo "<li><a href='{$path}index-$language'>$title</a></li>";
?>


menu-script.html


<?php

$file = 'breadcrumb.html';

$exp = array('/[^\/]/', '/^/', '/(?=(?<=\/)\/)/');
$rep = array('', '.', '..');
$path = preg_replace($exp, $rep, $_SERVER['PHP_SELF']);
$lang = $_SERVER['PHP_SELF'];

#breadcrumb in menu
while(strlen($path) > 3)
{
if(is_file($path . $file))
{
ob_start();
require($path . $file);
}
$path = substr($path, 0, max(0, strlen($path)-3));
}

$paths = array();
$output = array();
$sub = array();

foreach(glob('./*/'.$file) as $v)
{
$paths[] = preg_replace('/'.preg_quote($file, '/').'$/','',$v);
}


$count = count($paths);


#last color menu item
if($count != 0)
{
if(is_file($path . $file))
{
ob_start();
require($path . $file);
}
}


#grey menu with sub menus
foreach($paths as $path)
{
ob_start();
require($path . $file);
$output[] = ob_get_clean();
}


#grey menu no sub menus

if ($count == 0) {

//define the path as relative
$path2 = "..";

$dir_handle = @opendir($path2) or die("Unable to open $path2");

chdir( '..' );
while ($file2 = readdir($dir_handle))
{
if($file2!="." && $file2!="..") {

if (is_dir($file2)) {

array_push($sub, $file2);
}
}
}
sort($sub);


foreach($sub as $path) {
if(is_file($path . '/' . $file)) {
ob_start();
require($path . '/' . $file);
$output[] = ob_get_clean();

}
}

closedir($dir_handle);

}

// indent the output

$out = implode('', $output);


if ($out) {
echo '<ul>';
echo $out;
echo '</ul>';
}


?>


i realize that the code is an insane clusterfck but until a few weeks ago i had never coded in php and so far it seems to work!

TinaBanana
05-09-2007, 09:14 AM
nm i got it. had to replace this

foreach($sub as $v) {
if(is_file($v . '/' . $file)) {
$path = '../' . $v . '/';
ob_start();
require($v . '/' . $file);
$output[] = ob_get_clean();