[thelist] Efficient PHP?
live4bacon at optonline.net
live4bacon at optonline.net
Mon Mar 29 20:17:19 CST 2004
Another one for the PHP experts out there:
I am just discovering the wonderful world of PHP and I am curious if you all could spare a moment to tell me what you think of the efficiency of the following SIMPLE code (this would exist on all 60+ and growing pages of our site) that generates the sites sidebar navigational links, which are specific to each section, and shows the current page in bold text of a different color.
Nothing groundbreaking here.
If you think this may be of some use to you or you would like to examine the full code I will gladly pass it along.
Thank you,
JP
Basically I have an array holding:
1 an array of Page titles (for display in the sidebar of said section)
2 an array holding the file name for said pages
3 variable to hold the section graphic file
4 variable to hold the root relative path to the section directory
5 (OPTIONAL array to hold sub-section pages
6 (OPTIONAL array to hold sub-section page filenames)
function show_sidebar($cur_section, $cur_page = "none")
DEFINE ARRAY OF SECTIONS AND SUBSEQUENT ITEMS
DISPLAY SIDEBAR:
echo '<a href="'.$secRoot.'"><img src="/common/images/page_elements/'.$graphic.'"></a><br>';
if($arr_sbar_content[$cur_section]["pages"]){
echo '<div class="sbar_pad"><span class="sbar_nav">';
for ($i = 0; $i < count($arr_sbar_content[$cur_section]["pages"]); $i++){
if($arr_sbar_content[$cur_section]["pages"][$i] == $cur_page){
echo '<span class="current_page"><a href="'.$secRoot.$arr_sbar_content[$cur_section]["href"][$i].'">'.$arr_sbar_content[$cur_section]["pages"][$i].'</a><br></span>';
}
else{
echo '<a href="'.$secRoot.$arr_sbar_content[$cur_section]["href"][$i].'">'.$arr_sbar_content[$cur_section]["pages"][$i].'</a><br>';
}
}
echo '</span>';
ANOTHER IF STATEMENT FOR SUB-PAGES IF THEY EXIST goes here
More information about the thelist
mailing list