Archive for the ‘Web Design’ Category

osCommerce DHTML Drop Down Navigation Menu

Tuesday, April 29th, 2008

I have recently been working on re-skinning the Simply Lights website which was created (before I got my mits on it) using the osCommerce PHP/MySQL script. osCommerce has been around for years and is one of the most popular shopping cart systems available. It includes thousands of mods/plug-ins which are available to download and install either for free or for a small fee, one of which is Dynamenu which I have installed on the Simply Lights website. The reason I am posting it here is because it took me a good half a day of searching and testing to find a suitable mod that would simply create a DHTML drop down navigation menu and Dynamenu was by far the easiest and best from the selection I downloaded, and the best thing of all, it’s free.

The options allow you to choose the appearance of your navigation menu and includes the options of a horizontal drop-down, a vertical flyout, a tree menu (collapsible folders like windows explorer), a plain (without drop downs) horizontal menu or a plain vertical menu. To install Dynamenu you simply have to upload some files, change a few config settings and drop a line of PHP into the section of your page template where you want the menu to appear. Then it is just a case of restyling the CSS to suit your design.

I’m not a huge fan of osCommerce, I much prefer CubeCart, but once you understand how the files are structured then it becomes fairly easy to modify the PHP/HTML code and CSS.

Simple PHP Download Counter Script

Tuesday, February 26th, 2008

Here is a simple way to create a download counter script using PHP. It simply counts each click on the download link and stores the result in a writable text file.

First upload the file you wish users to download to your server. Then create a text file and name it “counter.txt“. Open the text file and add a 0, save and upload to your server and set the text file permissions to 777.

Now create a PHP file named “countdownloads.php” and add the following code:

<?php
$myFile = "counter.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

$theData = $theData + 1;

$myFile = "counter.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $theData);
fclose($fh);

header("Location: download.zip");
?>

Now add the following code to your HTML page that will display the link to your download:

<p><a href="countdownloads.php">Download File</a><br />
<?php
$myFile = "counter.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
echo $theData;
fclose($fh);
?> Downloads<br />
since Feb 2008</p>

Upload these files to the same directory on your server and that should do the trick. I’m using this script on AffiliStore to count the downloads of the software.

Close
E-mail It