You are here: Re: Dynamic site navigation « PHP Programming Language « IT news, forums, messages
Re: Dynamic site navigation

Posted by NC on 04/12/06 01:06

James Bates wrote:
>
> Hope someone can help me out with something - I'm a HTML/CSS
> developer who know's a little PHP, which I use to make smaller sites
> semi-dynamic, I want to expand on what i'm currently doing but need
> some help.

OK, but you may consider a change in the way you do things. Static Web
sites store content in files, with content embedded into presentation.
With a dynamic Web site, you have more options; you can (1) separate
contrent from presentation, and/or (2) choose to store content (whether
still attached to presentation or not) in files or in a database.

> I currently use PHP to create a single included .php file that contains
> the navigation,

Note that the reverse is also possible. You can have an index.php
file, which contains navigation, include content drawn from files or a
database.

> So (eventually) I get to my question... Rather than having a variable
> written into the top of each page, could I create a globals.php file
> that's included from everypage that knows what section that page is is
> from it's parent folder.

Yes. If your globals.php is included into another file, the
superglobal variable $_SERVER['PHP_SELF'] will tell it into what file
it has been included.

Try this: create two files, a.php and b.php.

a.php:

<?php include 'b.php'; ?>

b.php:

<?php
echo '<p>PHP_SELF=', $_SERVER['PHP_SELF'],
'</p><p>__FILE__=', __FILE__, '</p>';
?>

Then point your browser to a.php; the output will be:

PHP_SELF=/A/a.php
__FILE__=/A/b.php

In other words, b.php "knows" that its name is b.php and that it's been
included into a.php.

Cheers,
NC

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация