Random Banner Script using PHP
Written on 08/27 • 0 CommentsI wanted to start alternating the banner advertisements on this site so started looking around for the simplest way to randomly display a different banner in my case a few lines of code that included the link, image and some text. I found a number of scripts that all seemed a bit clunky. I started thinking there must be a better simpler way.
All the solutions I found used the php function rand. We end up having to generate a random number from a range e.g. rand (0,100); will give us a random number between 1 and 100. There are a few problems here, firstly the range needs to be set to reflect the number of banners we have in our array so therefore we end up having to count the items in the array or use a fixed number.
The problem with rand is it deals with integers not blocks of code. I started looking for an alternative and stumbled upon shuffle. Shuffle as you would expect takes our array and reorders it at random as you do with a deck of cards. If you shuffle a deck of cards hen take the top card you end up with a random card from the pack each time. The other good thing about shuffle is it shuffles the whole array without us having to specify the number of entries.
Continue ReadingMove Related Products to Centre Column in Magento
Written on 07/09 • 4 Comments
The default theme for Magento has the related products block on the left hand side which is not necessarily the best place for it. A more logical place to put related products is under the product description in the center column. It is simple to move the related products block but you need to know where to look.
Continue ReadingPassword Protecting Your Site with htaccess
Written on 07/02 • 0 Comments
It is sometimes handy to be able to password protect your pages or an entire site. Maybe you're building a new site, but you only want yourself and client to be able to view the work-in-progress. Apache allows you to fairly easily add password protect an entire site, folder or individual file.
Continue ReadingGranting Database Privileges in MySQL via SSH
Written on 03/26 • 1 Comments
This week I experienced some problems installing Magento the Open Source shopping cart system onto a dedicated server hosted by Wedfusion. The installation seemed to go well until just after the database was populated by the installer script. All the tables were created as expected but Magento produced a rather unhelpful general error. After some investigation it turned out that the issue was occurring because by default a database created in the server control panel do not assign the CREATE TEMPORARY TABLES privilege to the database user. To fix the issue all I needed to do was add the privilege to the user and the installer then works flawlessly. Below are some simple instruction on granting privileges in MySQL via SSH.
Continue ReadingCreate a Simple CSS Pin Map with Ease
Written on 03/19 • 1 Comments
It is easy to create a map with pins that you can position to correspond to a point of interest then hyperlink the pin to another page or get creative and use javascript to trigger an event. In this example we have a map of the UK with pins positioned roughly over the top ten cities by population. The pins link to the cities Wikipedia page and use the title attribute to show the name when hovering over the pin. This is a bare bones example for you to build on, you could use image sprites to change the image of the pin to a marker of your choice or use javascript to create information bubbles when you mouse over the marker the choice is up to you.
Continue ReadingMake a Dotted or Dashed Line in Photoshop follow a Path
Written on 02/12 • 0 Comments
Drawing a dotted line is easy in Illustrator. You just change it in the stroke palette. You would think it was just as easy in Photoshop but it is a little bit trickier. This short tutorial aims to show you how to quickly make a dotted or dashed line in Photoshop and then apply it to a curve.
Continue ReadingMore articles can be found in the archives, feel free to have a look around and leave your comments.
Save a massive 36% on a subscription to .net magazine!
We love .net magazine (known as "Practical Web Design" outside the UK) and have teamed up with Future Publishing to get our readers up to a massive 36% off a years subscription.
Mint