Recently, Jeffrey has been doing an awesome job covering the client side aspect of theme development by taking us on a “jQuery for absolute beginners” journey. While we often use Javascript and JS libraries such as jQuery and mootools on the clients side, its nice to incorporate some server-side functionality. This is most often accomplished with the easy to learn web language known as php. Today, we will cover some unique ideas and tutorials to help you incorporate some php functionality into your themes.
1.Scan image folders with php.
A great idea for photography and portfolio type themes is to have php scan the images folder for the client. For example, lets say you are building a photography theme. We could use php to scan a folder named ‘images’, extract the images, and echo them out in an unordered list. We could take it a step further by scanning two directories, one for thumbnails and one for full size images. How can we do this? Luckily, Jeff came to our rescue again and has an excellent post on scanning folders with php.

2.Create an AJAX contact form.
While AJAX (asynchronous javascript and xml) deals with the client side presentation, a server side script is still needed to perform the actual mail tasks. This gives us a perfect opportunity to use php with AJAX techniques to create an awesome contact form for the end user.

How do I do it?
- Creating an AJAX contact form from scratch.
- 16 free AJAX contact forms.
- Submit a form without a page refresh.
- AJAX contact forms-A how to guide.
3.Create dynamic thumbnails.
This one is extremely practical for a portfolio or any kind of template that will use thumbnails to display large images. Basically, we use php to take a large image and scale it down to thumbnail size. If we take this one step further and use php to scan a directory and then resize to thumbnails, you have quite an awesome script on your hands.

How do I do it?
4.Create a useful wordpress plugin
This one is for all of you excellent wordpress designers and developers on ThemeForest. One way to really catch the eye of a prospective buyer, is by including a custom wordpress plugin you’ve written that adds to that themes functionality. Sure, its a little extra work, but you will learn a lot about wordpress in the making and really will “wow” your buyers. In addition, its not as hard as you may think and there are some great tutorials on how to do this, such as the ones listed below.

How do I do it?
5.Create a user login.
If you haven’t noticed, admin themes have been a huge hit on ThemeForest with buyers. Its hard to argue against them with some of the talented designers building them. One thing I always wish some of them would incorporate however, is a working login system. This isn’t hard to implement if you’ve studied any bit of php, and you can do it with or without a DB. Keep in mind that buyers that use wordpress have to setup their own MySQL DB, so don’t be afraid to include one as long as you keep it simple and explain everything to the user.

How do I do it?
6.Parse an xml feed to display.
While this may not be for someone completely new to php, its quite easy now days to parse any kind of xml feed or file to display on a website. For instance, you could use a custom php script to display the users latest tweets. Anything that uses xml feeds or files you can parse, so get creative with it. Make sure to let the user know anything they need to change or update in the file as well.

How do I do it?
7.Switch up the styles with php
If your a JavaScript junkie, then by all means you can do this in Javascript. Unfortunately, if the user has JS disabled then they wont be able to switch the styles. We can use php to ensure all end users are able to switch and set (via sessions) their favorite styles. Furthermore, this is really quite simple to pull off with php and you can almost guarantee nowadays that the perspective buyer will have php installed on their server. Just make sure they know they need it!

How do I do it?
That’s it for now! Do any of you php gurus have some other techniques you like to use in your themes or websites? If so, please let us know in the comments below.
- Subscribe to the ThemeForest RSS Feed for more daily web development tuts and articles.




Michael Nichols
December 16th, 2008
Thank you so much for this… It is really going to help!
tristen
December 16th, 2008
Great list and great dynamic additions to simple websites for clients. I’m digging into this right now and learning some short form code I wasn’t aware of!
Joseph Dearman
December 16th, 2008
Great list! Thanks.
chrispugh
December 16th, 2008
Thank you for posting this, very useful information.
Drew
December 16th, 2008
Glad to hear you all enjoyed it, thanks for the nice words
chris
December 17th, 2008
Great Article.
Susan
December 17th, 2008
This is a good list of ideas!
arakno
December 18th, 2008
Excellent resource! Allow me to add these links covering xml manipulation with php:
http://alternateidea.com/blog/articles/2004/7/23/simplexml-and-xpath-in-php5
http://www.phpfreaks.com/tutorial/handling-xml-data/page1
The IBM link posted didn’t work for me, try this:
http://www.ibm.com/developerworks/xml/library/x-xmlphp2.html
Vasili
December 20th, 2008
Great tips. I’m thinking about submitting something here and these ideas would be great to add.
koen buysse
January 2nd, 2009
about number1 tip:
in stead of creating or finding a separate script that automaticaly creates the thumbs….why not select the same images folder as the thumbs folder????
the images are sized down using css anyway … (width= 50 px)
plus, if the image isn’t fully loaded, he thumb isn’t visible…therefore it’s impossible to have a waiting time for viewing the image when you clicked on a thumbnail…
anyway ! great tips !!!!
more more more !!! :p
koen buysse
January 2nd, 2009
to clear up my previous comment:
if the main images are under images/main images/
and the thumbs are under images/thumbs/
just tell the script to get the thumbs from images/main images, and you can delete the thumbs folder….
thumbs are created using css…
sorry for my poor english.
Juilloferfelo
January 7th, 2009
There are 5 houses in five different colors
In each house lives a different nationality.
These 5 owners drink a certain beverage, smoke a certain brand of cigar and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.
The CLUES:
The Brit lives in the Red house.
The Swede keeps dogs as pets.
The Dane Drinks tea.
The Green House is on the left of the White House.
The Green House’s owner drinks coffee.
The person who smokes Pall Mall rears birds.
The owner of the yellow house smokes Dunhill.
The man in the center house drinks milk.
The Norwegian lives in the first house.
The man who smokes Blends lives next to the one who keeps cats
The man who keeps horses lives next to the man who smokes Dunhill.
The man who smokes Blue Master drinks beer.
The German smokes Prince.
The Norwegian lives next to the Blue House.
The man who smokes Blends has a neighbor who drinks water.
The QUESTION:
Who owns the fish?
Jeffrey
January 8th, 2009
None of them own a fish.
TJ
January 30th, 2009
Nice tutorial! Love links to new resources. Thanks.
Dave
June 10th, 2009
Thank you for the tips! I just wanted to let you know that the css style switcher tutorial from ALA is pretty old (7 years) and no longer works with PHP 4 or 5. The second link works great though.
I ended up using an altered variant of the ALA idea for my site. I just made some replacements (used the $_POST and $_COOKIE arrays) and used a hidden input to pass $_SERVER['SCRIPT_URL'] to switcher.php ($HTTP_REFERER doesn’t work a lot of the time).