Current location: Hot Scripts Forums » Programming Languages » PHP » Output page by file name


Output page by file name

Reply
  #1 (permalink)  
Old 10-29-04, 01:02 PM
deanloh deanloh is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Output page by file name

I have thought very hard on this yet I'm still clueless, hope someone can help me in this:

I'm trying to maintain just one header template, yet I would like the output of home page (index.php) different than the sub pages, i.e. sub pages have a navbar on the left, and home page doesnt.

Basically, what I was trying to achieve is: if this is not index page, add a column for navbar. So I added these codes to my header template:

Code:
...
<table>
<tr>
<?
if (ereg('/home/***/public_html/index.php', $_SERVER['SCRIPT_FILENAME'])!=true) {
echo '<td>navbar for subpages</td>';
}
<td><!--header ends here-->
?>
Obviously it didnt work as the code
Code:
$_SERVER['SCRIPT_FILENAME']
outputs the header template's filename intead.

Question: is there a way to output the filename of the page? How can I better achieve this objective?

Any little hint will be much appreciated!
Reply With Quote
  #2 (permalink)  
Old 10-29-04, 01:13 PM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
i assume you don't go into parent and child directories.
this code should fix:
PHP Code:

if (!eregi('index.php'$_SERVER['PHP_SELF'])) {

echo 
'<td>navbar for subpages</td>';

__________________
just an ignorant noob with moronic solution...
Reply With Quote
  #3 (permalink)  
Old 10-29-04, 01:25 PM
deanloh deanloh is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the quick reply moronovich, I tried with your code, it still wont work. Problem is: the $_SERVER['PHP_SELF'] code actually outputs the name of the header i.e. /inc/header.php therefore theres no way it will match the index.php

Am getting headache already...

Last edited by deanloh; 10-29-04 at 01:27 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Ordering output of fgets() from text file AutoObsession87 PHP 2 03-25-04 01:26 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM
Login page and the web.config file andreasberglind ASP.NET 3 12-26-03 06:40 PM


All times are GMT -5. The time now is 04:41 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.