| DragnDrop |
UserPreferences |
| cornerhost wiki | FrontPage | RecentChanges | TitleIndex | WordIndex | SiteNavigation | HelpContents | moin.sf.net |
back to PhpPrentice
Here is the outcome I was looking for: in order to add a project description page for a new project, all I want to do was add "newproject.jpg" "newproject.txt" and "newproject.html" to the server. Then, "newproject.html" will recognize the contents of "newproject.txt" as the project description, and "newproject.jpg" as the project thumbnail. The rest of "newproject.html" will contain the same html content as all other project description pages on the site. This script was tailored for a "picture gallery" style site.
<?php
#get the enviroment variable of the current page.
#if you're going to me.com/site/test/whatever.php
#then this is /site/test/whatever.php
$script=$_SERVER['SCRIPT_NAME'];
#get the name of the directory
#which is just "/site/test" (no trailing "/")
$dir=dirname($script);
#replace "/site/test" and the trailing "/" with ""
#the ^ means 'start at the begining of the string in this context
$file=ereg_replace("^$dir/","",$script);
#replace the ".php" at the end of the file name with ""
#the \ is to escape the . since a . by itself means "any character"
#and we want a literal .
$name=ereg_replace("\.php$","",$file);
#name is now just "whatever" so you can play with it to your
#heart's content by including "whatever.txt" from the same dir include("$name.txt");
#since your result will be html, you may wish to put code around the
#include to mark it up so you can stick to just raw content in your .txt
#file.
#or linking to "whatever.jpg"
?>
<hr>
<img src="<?=$name?>.jpg">
#Jpegs of each project show up on using this naming convention in the html
<a href="<?=$name?>.pdf">
#Higher resolution PDFs of each project are linked in the template with this naming convention in the html
This script was masterfully written by
Phillip Harrington and additionally modified by
Al-Insan Lashley
The page can be found at:
alinsan.net
back to PhpPrentice