Current location: Hot Scripts Forums » Programming Languages » PHP » PHP (pull the filename)


PHP (pull the filename)

Reply
  #1 (permalink)  
Old 02-23-06, 03:53 PM
pcinfoman pcinfoman is offline
Coding Addict
 
Join Date: Jan 2006
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
PHP (pull the filename)

I am trying to edit alot of my web pages and change the link to a particular are. What I have is two folders with the exact same filenames in each folder.

Eg. I have a folder named "Rentals" and another folder named "RentalsPrintable". Each folder has the exact same files in them ("RentalsPrintable" files are modified to be printable versions of the "Rentals" pages).

The files in the "Rentals" folder are using php to include a common navbar. What I would like is a piece of php on the included navbar file that will pull the filename (minus the .php) from the page it is currently on so I do not have to modify each and every page.

Eg link. "/RentalsPrintable/+filename (minus the extension) + .html" Where "filename" is the php generated value.

I am not sure if this makes sense. Do you understand what I am looking for?
Reply With Quote
  #2 (permalink)  
Old 02-23-06, 04:04 PM
ben.periton ben.periton is offline
Wannabe Coder
 
Join Date: Oct 2004
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
This will pull just the name of the file, and put it into the var; $filename.
Then you can just use it like:

/RentalsPrintable/<?php echo $filename?>

PHP Code:

<?php

    $file 
$_SERVER["PHP_SELF"];
    
$file_parts explode('/'$file);
    
$filename substr($file_parts[2],0,-4);
    
    print 
$filename;
?>
__________________
Ben Periton
http://ben.periton.co.uk
Reply With Quote
  #3 (permalink)  
Old 02-24-06, 01:32 AM
sensationdesigns sensationdesigns is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Just for the sake of it - have you considered having PHP "make" the pages printer-friendly, or even using a separate stylesheet for printing? (#nav { display: none })

I think it is overhead to have two "identical" pages for two different purposes... do that behind the scenes, or get stressed when you want to update and just forget to make the change to both...
__________________
SonicMailer Pro - Professional PHP mailing list manager
Follow the development of version 3!
Exhaustive list of new & improved features being implemented!
Reply With Quote
  #4 (permalink)  
Old 02-24-06, 10:17 AM
pcinfoman pcinfoman is offline
Coding Addict
 
Join Date: Jan 2006
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sensationdesigns
Just for the sake of it - have you considered having PHP "make" the pages printer-friendly, or even using a separate stylesheet for printing? (#nav { display: none })

I think it is overhead to have two "identical" pages for two different purposes... do that behind the scenes, or get stressed when you want to update and just forget to make the change to both...
It sounds like a good idea, but that is way beyond my skills. I am very skilled in html, but my knowledge of php is shameful at best. On top of that, the printable page needs to have a different header (no navigation at all) and needs to page break after each individual product as well as putting the header at the top of each page. Can this be done?

Quote:
Originally Posted by XTech
This will pull just the name of the file, and put it into the var; $filename.
Then you can just use it like:

/RentalsPrintable/<?php echo $filename?>

PHP Code:

 <?php
     $file 
$_SERVER["PHP_SELF"];
     
$file_parts explode('/'$file);
     
$filename substr($file_parts[2],0,-4);
     
     print 
$filename;
 
?>
Thank you for the code
Reply With Quote
  #5 (permalink)  
Old 02-24-06, 12:00 PM
sensationdesigns sensationdesigns is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Can be done both via CSS and PHP. How do you have page breaks, though?

One printer may have margins of 0.5, another of 2.5... ?
__________________
SonicMailer Pro - Professional PHP mailing list manager
Follow the development of version 3!
Exhaustive list of new & improved features being implemented!
Reply With Quote
  #6 (permalink)  
Old 02-24-06, 12:39 PM
pcinfoman pcinfoman is offline
Coding Addict
 
Join Date: Jan 2006
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sensationdesigns
Can be done both via CSS and PHP. How do you have page breaks, though?

One printer may have margins of 0.5, another of 2.5... ?
I am trying not to hassle the difference between printers issues. I am simply adding a <br style="page-break-before:always;"> where I want a page break.
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
Javascript (pull the filename) pcinfoman JavaScript 2 02-23-06 03:50 PM
PHP Meta Tag Pull / Search dm18k Script Requests 0 09-23-05 03:33 PM
PHP Downside--Solutions? Amulet PHP 10 07-15-05 08:26 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP / Graphic Developers someotherguy582 Job Offers & Assistance 1 06-05-05 07:40 PM


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