stbearabus Posted June 3, 2008 Share Posted June 3, 2008 Howdie, I am new to php and find myself in a rough spot. I have to modify the navigation of an existing php script that is being used as an image gallery. The NavDisplay is currently set up with a sub head followed by the items to be displayed to the right. The Navdisplay refers to an include file with a list of all the .sub and image/movie files. The art director in my office wants to add another sub category underneath the sub head and move all the display files to the right. Like so. Subhead SubCategory: Display file1a Display file 2a Display file 3a SubCategory: Display file 1b Display file 2b etc etc.. So based on my limited knowledge, i have been able to address the problem and localize where I need to make changes, but i can't seem to figure out a way to make it happen. No looking for someone to rewrite this, but could really use some direction. Was looking for any advice or knowledge you guys could give! I am including the code if that is helpful. Thanks! Seth [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/ Share on other sites More sharing options...
DarkWater Posted June 3, 2008 Share Posted June 3, 2008 Can you please just post the relevant code? wget doesn't seem to want to be friendly with SMF's download system, and I don't feel like having to do it manually. Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/#findComment-556866 Share on other sites More sharing options...
stbearabus Posted June 3, 2008 Author Share Posted June 3, 2008 Sorry, new to using forums. I am including all the php content below. I have left out the css and the html material. Code: <?php if (isset($_GET['client'])) { $client = $_GET['client']; } else { // ++++++++++++++++++++ // // Client Listing Array // // ++++++++++++++++++++ // $DirectoryToScan = 'work'; $dir = opendir($DirectoryToScan); while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_dir($FullFileName)) { if ($file == "." || $file == "..") { // do nothing } else { // insert the projects into a multidimensional array $clientListingArray[] = $file; } } } unset($DirectoryToScan, $dir); $client = $clientListingArray[0]; } // include getID3() library (can be in a different directory if full path is specified) require_once('getid3-1/getid3/getid3.php'); // Initialize getID3 engine $getID3 = new getID3; $DirectoryToScan = 'work/'.$client; // change to whatever directory you want to scan $dir = opendir($DirectoryToScan); while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_file($FullFileName)) { if ($file == "." || $file == ".." || $file == "order.inc" || $file == "Logo.gif") { // do nothing } else { set_time_limit(30); $workFilesArray[] = $file; } } } $workFilesArrayCount = count($workFilesArray); // Determine if there is an order.inc file in the main directory to sort the sub directories in a certain order: // If the files doesn't exist, then: if(!@file_exists($DirectoryToScan.'/order.inc') ) { sort($workFilesArray, SORT_STRING); $orderedWorkFilesArray = $workFilesArray; // If the file does exist, then: } else { // import the file specifying the order of the files include($DirectoryToScan."/order.inc"); // create a new array for just the file names $filesArray = array(); // come up with a master array that orders and appends any lingering files to the end of the array for ($i=0; $i<count($fileOrderArray); $i++) { $orderedFileListName = $fileOrderArray[$i]; $key = array_search($orderedFileListName, $workFilesArray); if($key!==null&&$key!==false) { $filesArray[] = $orderedFileListName; unset($workFilesArray[$key]); } unset($key); } // take the remaining entries from the naturally created array and tack them on to the end of the new ordered file listing array $orderedWorkFilesArray = array_merge($filesArray, $workFilesArray); } $orderedWorkFilesArrayCount = count($orderedWorkFilesArray); for ($i=0; $i<$orderedWorkFilesArrayCount; $i++) { $subTitleCheck = substr($orderedWorkFilesArray[$i], -4); if ($subTitleCheck == ".sub") { $displayNameSuffix = substr($orderedWorkFilesArray[$i], 0, -4); $navDisplay .= "<span class=\"subheadtitle\">".$displayNameSuffix."</span><br />\r\n"; } else { $typeShorthand = array('_p', '_r', '_t', '_w'); // $typeLonghand = array(' [print]', ' [radio]', ' [tv]', ' [web]'); $typeLonghand = array('', '', '', ''); $displayNameCategory = str_replace($typeShorthand, $typeLonghand, $orderedWorkFilesArray[$i]); $displayNameSuffix = substr($displayNameCategory, 0, -4); $displayName = str_replace("_", " ", $displayNameSuffix); $navDisplay .= "<a href=\"?client=".$client."&workID=".$i."\">".$displayName."</a><br />\r\n"; } } if (isset($_GET['workID'])) { $workID = $_GET['workID']; } else { $workID = 1; } $FullFileName = realpath($DirectoryToScan.'/'.$orderedWorkFilesArray[$workID]); $ThisFileInfo = $getID3->analyze($FullFileName); getid3_lib::CopyTagsToComments($ThisFileInfo); // output desired information in whatever format you want $fType = strstr($orderedWorkFilesArray[$workID],"."); //gets extension $fName = $ThisFileInfo['filename']; // import filetype.inc to correctly display the files based on extension include("filetypes.inc"); Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/#findComment-556872 Share on other sites More sharing options...
DarkWater Posted June 3, 2008 Share Posted June 3, 2008 Please put your code in tags so it's easier to read. Also, can you please take a screen shot of what it currently looks like for me? Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/#findComment-556876 Share on other sites More sharing options...
revraz Posted June 3, 2008 Share Posted June 3, 2008 Tags make it easier to read <?php if (isset($_GET['client'])) { $client = $_GET['client']; } else { // ++++++++++++++++++++ // // Client Listing Array // // ++++++++++++++++++++ // $DirectoryToScan = 'work'; $dir = opendir($DirectoryToScan); while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_dir($FullFileName)) { if ($file == "." || $file == "..") { // do nothing } else { // insert the projects into a multidimensional array $clientListingArray[] = $file; } } } unset($DirectoryToScan, $dir); $client = $clientListingArray[0]; } // include getID3() library (can be in a different directory if full path is specified) require_once('getid3-1/getid3/getid3.php'); // Initialize getID3 engine $getID3 = new getID3; $DirectoryToScan = 'work/'.$client; // change to whatever directory you want to scan $dir = opendir($DirectoryToScan); while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_file($FullFileName)) { if ($file == "." || $file == ".." || $file == "order.inc" || $file == "Logo.gif") { // do nothing } else { set_time_limit(30); $workFilesArray[] = $file; } } } $workFilesArrayCount = count($workFilesArray); // Determine if there is an order.inc file in the main directory to sort the sub directories in a certain order: // If the files doesn't exist, then: if(!@file_exists($DirectoryToScan.'/order.inc') ) { sort($workFilesArray, SORT_STRING); $orderedWorkFilesArray = $workFilesArray; // If the file does exist, then: } else { // import the file specifying the order of the files include($DirectoryToScan."/order.inc"); // create a new array for just the file names $filesArray = array(); // come up with a master array that orders and appends any lingering files to the end of the array for ($i=0; $i<count($fileOrderArray); $i++) { $orderedFileListName = $fileOrderArray[$i]; $key = array_search($orderedFileListName, $workFilesArray); if($key!==null&&$key!==false) { $filesArray[] = $orderedFileListName; unset($workFilesArray[$key]); } unset($key); } // take the remaining entries from the naturally created array and tack them on to the end of the new ordered file listing array $orderedWorkFilesArray = array_merge($filesArray, $workFilesArray); } $orderedWorkFilesArrayCount = count($orderedWorkFilesArray); for ($i=0; $i<$orderedWorkFilesArrayCount; $i++) { $subTitleCheck = substr($orderedWorkFilesArray[$i], -4); if ($subTitleCheck == ".sub") { $displayNameSuffix = substr($orderedWorkFilesArray[$i], 0, -4); $navDisplay .= "<span class=\"subheadtitle\">".$displayNameSuffix."</span> \r\n"; } else { $typeShorthand = array('_p', '_r', '_t', '_w'); // $typeLonghand = array(' [print]', ' [radio]', ' [tv]', ' [web]'); $typeLonghand = array('', '', '', ''); $displayNameCategory = str_replace($typeShorthand, $typeLonghand, $orderedWorkFilesArray[$i]); $displayNameSuffix = substr($displayNameCategory, 0, -4); $displayName = str_replace("_", " ", $displayNameSuffix); $navDisplay .= "<a href=\"?client=".$client."&workID=".$i."\">".$displayName."[/url] \r\n"; } } if (isset($_GET['workID'])) { $workID = $_GET['workID']; } else { $workID = 1; } $FullFileName = realpath($DirectoryToScan.'/'.$orderedWorkFilesArray[$workID]); $ThisFileInfo = $getID3->analyze($FullFileName); getid3_lib::CopyTagsToComments($ThisFileInfo); // output desired information in whatever format you want $fType = strstr($orderedWorkFilesArray[$workID],"."); //gets extension $fName = $ThisFileInfo['filename']; // import filetype.inc to correctly display the files based on extension include("filetypes.inc"); Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/#findComment-556879 Share on other sites More sharing options...
stbearabus Posted June 3, 2008 Author Share Posted June 3, 2008 Ok, including a pic. I appreciate the help. Will put code in tags next time. Hope putting the picture via post works right. Picture illustrates the navigation on the left. Logo on top, list below. On the right is where the pics/movies are displayed. Thanks again! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/108589-php-navigation-help/#findComment-556887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.