Page 1 of 1

Ultra simple Flat File Link List UDT

Posted: Mon Oct 15, 2007 8:13 am
by Mury
Hi folks,
This is an ultra simple way to make a link list using a flat text file as the database, great to make up a simple easily updated list.
Obviously the link can be to anywhere or anything. file, image whatever. 
It doesnt even have to be a link I suppose - it could be a <img src="image.gif etc etc - you just gotta replace that part of the echo.  The script is VERY basic. Basically it is a UDT that calls a text file and loads the links listed there.  Installation is described in the script.
Steps :
1 create a text file as described in the script
2 copy the following code into a new UDT , I've called it {lister1}

Code: Select all

// An Ultra simple Flat File Link List
// See it in use on gmwit.com
// First - create your TXT file using Notepad or similar. Data is entered onto a new line.
// Each data item is in the format is URL@DESCRIPTION
// Save the TXT file and FTP it to your server.  The directory is given in the File_handle variable.
// Im using the full path from the root Dir eg "/home/yourroot/public_html/filedirectory/filename.txt"
//
// To use with CMS Made Simple, Place this code into a User Defined Tage (UDT) and name it whatever you want
// If you rename the tag, then you must also rename the tag in the Template
// Note - this example calls this UDT {lister1}
//
// To use it as a normal PHP script, replace the <?php and ?> tags and remove the " escape characters.
// Warning - There are no bells or whistles
//
// modify $File_handle to the exact path to your file, se above
//
 $file_handle = fopen("path to your file goes here", "rb");
//
while (!feof($file_handle) ) {

$line_of_text = fgets($file_handle);
$parts = explode('@', $line_of_text);

// you can modify the link layout if you want, $parts[0] is the link, $Parts[1] is the description

    echo "<a href=$parts[0] target=\"_blank\">$parts[1]</a>"."<br />";

}

fclose($file_handle);

//end of the script
3 Create the Page for the link list to go on and insert this code (use the HTML editor)

Code: Select all

<br>
<div style="width:425px ;text-align:left;border:1px solid #CCCCCC;padding:10px;">
<span style=" font-family: Arial,Verdana; font-size: 12px; color:black; line-height:12px">
your text goes here - the text formating is just something I've left in.<br>
You can safely remove both the "div" and the "span" components.
Enjoy.
</span><br><br>
{lister1}

</div>
4 Umm thats it, enjoy. You can see it working here : http://www.gmwit.com/gmw_main/index.php?page=video-list
If someone comes up with improvements, please let me know, my PHP is limited :)
Keep well