We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12027
    • 63 Posts
    On a demoscene site, http://scoopex1988.org/downloads.html there will be a simple page consisting of one list for each year (or subdirectory on the site). Now, we all know Firefox has its issues with FTP links, and the demos will be uploaded to those subdirectories by members.

    The optimum would of course be if we could write (or generate?) some database with release date, credits, platform, screenshot, etc - but I don’t see that we have the time to do it.

    The minimum would be alphabetically sorted filenames with an optional clickable thumbnail or icon if a screenshot or article is written for it. (i.e. a link to ’new article’ with QuickEdit controls.


    Any cool ideas on how to do this?

    Something like:

    <h3>1989</h3>
    <a href="...">Amiga-FirstDemo.lha</a> -- <a href="AddArticle.html">Info</a>
    <a href="...">Amiga-JOE-Graphics.adf</a> -- <a href="AddArticle.html">Info</a>
    <h3>1999</h3>
    <a href="...">PC-TunnelDemo.lha</a> -- <a href="AddArticle.html">Info</a>
    etc.

    I don’t see "new documents" as a necessity, in fact it could be even cooler with a fold-out article or pop-over on hover.

    It’s quite a bit of entries, so automatically reading subdirectories and making lists would be good. Another option could be to create documents for each demo, but is there a way for relative newbies to do this efficiently?


    Yet another option might be to just show the (http?) directory, if it can be styled to fit the site design. No possibility of screenshot and article though, unless you simply add a .png and a .txt with the same name.
      • 12027
      • 63 Posts
      Hm, this will generate html lists that I can use as content? How would I add that small article for each file that some members could write?

      Maybe I could make a form that is accessible for web users and allows them to create a now document and point to a demo in the site folders to create a link?
        • 3749
        • 24,544 Posts
        Here’s a snippet I wrote to display links to a set of newsletter .pdf files.

        It requires the newsletter filenames to be in a particular format and doesn’t include any subdirectories but it might give you some ideas:

        <?php
        
        // Shows all files in the newsletter directory,
        // descending by year,
        // assending by issue number within each year.
        
        // Filenames must be in format: yyyy-nn-MonthName
        // e.g. 2007-02-February
        
        $newline = "<br/>";
        $dir = $modx->config['base_path'].'assets/newsletters'; // set path to newsletter files
        $dir_array = array(); // main array - contains all file names in directory
        $temp_array = array(); // temp array used to hold one year's file names
        
        // open directory and parse file list 
        if (is_dir($dir)) { 
           if ($dh = opendir($dir)) { 
           
              // iterate over file list to create full directory array
              
              while (($filename = readdir($dh)) !== false) { 
                  if (($filename != ".") && ($filename != "..") && ($filename != "WS_FTP.LOG")) { // skip self, parent, and ftp log
        
        		  	$dir_array[] = $filename; // add the filename to the array
        
                  } 
              } 
        
              closedir($dh);  // close directory 
           }
           natsort($dir_array); // sort in ascending order by year and issue number
           $dir_array = array_reverse($dir_array, false); // reverse array (descending by year)
              
           $year = ""; // used for comparison to find new year
           $i = 0;
           $n = count($dir_array); // total number of files
           
           for($i=0;$i<$n;$i++) {  // can't use foreach() here -- need to manipulate index
        	    
           		$file_year = substr($dir_array[$i],0,4);  // year is first four characters of file name
        		
        		if ($file_year != $year) {  // new year
        			echo "<h3>    ",$file_year,"</h3>";
        			
        			$j = $i;  // set j (temporary index) to beginning of the new year
        			
        			$temp_array=array(); // empty $temp_array
        			$year = $file_year;  // set $year to current year
        			while($year == substr($dir_array[$j],0,4)) {  // build temp array for one year
        			
        			    if ($j > $n) {  // don't go beyond end of full array
        					break;
        				}
        				//$value = $dir_array[$j];
        				//$temp_array[] = $value;
        				$temp_array[] = $dir_array[$j];  // add one issue to temp_array
        				
        				$j++;
        			}
        			
        			
        			$temp_array = array_reverse($temp_array, false); // reverse array to show ascending months
        			
        			foreach($temp_array as $temp_value) {  // create one year's links on screen
        			
        			    $link = $modx->config['base_url'].'assets/newsletters/'.$temp_value;
                
        				echo '        <a href ="';
        	         	echo $link;
              			echo '">';
        				echo $temp_value;
        				echo '</a>';
                     	echo $newline;
        			}
        			$j--;  // decrement j because we went one too far
        			$i = $j;  // set  main index to beginning of next year
        			$year = $file_year;  // set $file year for start of new year
        		}
          
         
        	}
         
        } 
        echo $newline;
        
        ?>


        Hope this helps,

        Bob
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 7231
          • 4,205 Posts
          The FileDownload snippet handles this well also:
          http://www.modxcms.com/FileDownload-502.html
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]