<?php
function DeepDirTitle($step) {
$tracer = debug_backtrace();
$deep1020 = dirname($tracer[1]['file']);
$deepPath = dirname($deep1020, $step);
if ($step > 0) {
echo basename($deepPath);
} else {
echo basename($deep1020);
}
}
?>
i use this code in the SpeciesHeader.php template.
if i don’t use backtrace, then the dir names are called from the nature folder outside of the root. i want the dir names from the directories holding the index files that include the SpeciesHeader.php template.
Birds
DeepDirTitle(3) reveals Aves as the title.
using echo basename($deep1020); i can show the scientific species name without typing it into the html.
the directory holding all bird files is named using scientific nomenclature as Aves for birds.
Thus, the title will sow Aves and i now don’t have to type the title on thousands of species pages. Thus, php codes for me.
i don’t know of a better way.
i’m not familiar with classes and i have no idea how to implement a class with my design.
here is the actual setup outside of root:
[dir named nature]
SpeciesHeader.php
SpeciesFooter.php
[dir named Aves]
Turdus-migratorius.php
[dir named Genus]
Turdidae.php
here is the actual setup in www root:
[dir named start]
[dir named kingdoms]
[dir named Animalia]
[dir named Vertebrata]
[dir named Aves]
[dir named Turdidae]
[dir named Turdus]
[dir named migratorius]
index.php loads speciesheader.php, turdusmigratorius.php and speciesfooter.php from nature directory outside of root.
php should be able to help me build pages so that i don’t have to type all of the names again. I named the folders/directories all ready.
i want to read the directory names in the www root folders from the nature folder outside of the root.
i don’t want to pass data to the files outside of root, such as query strings and i see no reason to use a form or session variables.
the backtrace method is working well for me but will it also work on a live server?
do you suggest a better and hopefully easier method?
really i think that if it works on a real server, then it is brilliant code because it saves me hours and hours of typing html. i have thousands of species pages and it is too much work to type everything.
Thank you for reading and replying.