Archive | PHP RSS feed for this section

Wordpress : get_pages

4. May 2008

0 Comments

The Wordpress get_pages function works similar to the get_posts function which fetches posts from the database by criteria. The get_pages function takes different arguments and allows you to take control of parent and child pages as you execute the function.

Continue reading...

PHP : Strip filename from a URL

26. April 2008

0 Comments

Using PHP, you might need to strip the path from a URL, leaving behind just the filename at the end of the URL. You can achieve this with a regular expression pattern of course, but I have a much simpler solution. See the example code below.

Continue reading...

CakePHP : Form Radio Default Checked Value

17. April 2008

0 Comments

With the CakePHP FormHelper, you can output a set or a list of radio button widgets.

Continue reading...

CakePHP Crontab

28. February 2008

1 Comment

Due to the way that CakePHP rewrites URL requests with its router, it might seem confusing to execute a Crontab to run a controller action. I will show you how to set up a cron dispatcher so that you can execute all your different controller action schedules on a single file and pass the controller [...]

Continue reading...

PHP : Cannot use a scalar value as an array

26. February 2008

1 Comment

I was working on a Wordpress plugin today and came across the most disturbing PHP warning error which I have never seen before in all the time that I’ve worked with PHP. The warning error message was : Warning: Cannot use a scalar value as an array What caused this error was when I tried to append [...]

Continue reading...

PHP : Random string with numbers and letters

1. October 2007

7 Comments

I thought that some of you might find it useful to learn how to generate a string with random numbers and letters. I wrote a quick function for generating a string like this. See it below : function genRandomString() {     $length = 10;     $characters = ‘0123456789abcdefghijklmnopqrstuvwxyz’;     $string = ”;         for [...]

Continue reading...

PHP : Strip or find a file extension

29. September 2007

0 Comments

Getting a file’s extension is essential when working with uploads and other manipulations complying with files. You might have a user uploading a file and you need to rename the file before moving it from the temporary upload directory. In order to do so, you can obtain the file extension and then rename it to [...]

Continue reading...

Wordpress Pagination Class

28. September 2007

0 Comments

I wrote a simple, yet extremely useful Wordpress pagination class. The class is not complete yet, and I work on it as I move along and need new features or actions. So you have the freedom to take the class and customize/expand it as you might need to. First off, you can download the class [...]

Continue reading...

Wordpress Mailing List v2.0

28. September 2007

0 Comments

The Wordpress mailing list plugin v2.0 has been released to the public with a great set of new features. These features include : Multiple mailing lists Email scheduling Newsletter templates Automatic updates indicator Improved sidebar widget with Ajax Post/page opt-in form embedding Email queue CSV and MacOS Address book importing Excel CSV file exporting And much, much more… If you are upgrading from v1.X, you immediately [...]

Continue reading...

CakePHP : Delete multiple records

20. September 2007

1 Comment

With CakePHP, you can remove multiple records from a database table using the deleteAll() model method. deleteAll() Usage $this -> Model -> deleteAll($conditions, $cascade = true); Lets say that you wanted to remove all the records for a specific user from the Item model. Below is a quick example. deleteAll() Example $this -> Item -> deleteAll(array(‘Item.user_id’ => 13)); …where 13 would [...]

Continue reading...