thephpx
codeigniter, php, mysql, xhtml, css, jquery, flex web-development blog
codeigniter, php, mysql, xhtml, css, jquery, flex web-development blog
Jul 26th
Use of input array objects in ajax based forms where we want to give users open ended options to add unlimited number of items and then process them on form submission is very common now a days. As the input elements all have the same name and assuming no class or id attribute is available, validation can be a big pain in the back side.
The following code excerpt shows how to validate in such a scenario -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy for Windows (vers 14 February 2006), see www.w3.org" /><meta http-equiv="content-type" content="text/html; charset=us-ascii" /><title>Hello World</title><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript">//<![CDATA[function checkname(fieldname){var field = document.getElementsByName(fieldname+"[]");var status = 1;for(i=0;i<field.length;i++){if(status > 0){if(field[i].value == ''){status = 0;}}}if(status == 0){alert('The field can not be empty!');}}//]]></script></head><body><form method="post" action="" name="form" id="form"><input type="text" name="faisal[]" value="" /><input type="text" name="faisal[]" value="" /><input type="text" name="faisal[]" value="" /><input type="text" name="faisal[]" value="" /><select name="ahmed[]"><option value="">None</option><option value="1">1</option></select><input type="submit" value="test" onclick="checkname('ahmed');" /></form></body></html>
Comments and queries are welcomed
thephpx
Jun 20th
Hello everybody,
I have just created a short helper to create facebook like button dynamically for any content, by just giving-in the URL of the page. Hope this one also helps you like my other helpers
Helper function:
Usage:
Note:
As you can see the function requires you to use the codeigniter’s native URI helper.
May 16th
Hi I am back again,
This time with two helper function that lets you call any function from any model or library, given you already have the model or library loaded into the instance.
This one calls a library function with a single parameter being passed.
The next one calls a model function with a single parameter being passed.
As of now multiple parameter are not yet supported but I will soon post an extension of these two functions that will support multiple parameters. If you choose to use any of these functions feel free to use but a link back to my site is appreciated
thanks,
thephpx
May 12th
Recently I decided to give some more time to my blog and write some short but interesting posts. I will be writing some posts about custom helper functions that I have written which helps me in application development.
First on the list is a absolute path helper which creates an absolute path, relative to the base of the application. I call this function base_path(‘relative/url’);
The above is the code which will go into your helper file. The function formulates an absolute url from the given relative path based on base path of the application directory. It uses the existing base_url() helper function in codeigniter. So, you have make sure the URL helper is already loaded.
Example:
Suppose you want to tag an image which is located at “application-root/images/picture.jpg” to give its absolute URL in the img tag you can type as follows in your template/view file.
If you application is hosted at domain.com then it will give http://www.domain.com/images/picture.jpg as the returned path where http://www.domain.com/ is the base_url();
thanks,
thephpx
Oct 25th
Hi all,
I came across “Simple HTML DOM Parser” recently that allows jQuery like DOM selection. This function is quite handy to do some kungfoo DOM manipulation on the fly!
I needed to use it on codeIgniter so modified the files and integrated it into a single codeIgniter library. The original files can be accessed from here its sourceforge project page. For the codeigniter version of the library click here.
For further utility functions of the DOM parser visit this link.
Feel free to comment or contact me directly for any query.
take care,
thephpx
Sep 8th
Today I am going to share a little customization that I do while i develop codeigniter based web application. Now a days in most web application development firms a three-tire development process is followed. This is done to ensure smooth roll-out of the application from development to live.
The three-tire development methodology involves three stages of development servers. First comes the local server which is setup in your laptop or workstation. Then comes the internal test server, which is a central server that holds all the SVN repository as well as hosts the site and make it accessable to all from within the network. This server is also sometimes called staggin server. Last but not the least comes the live server, in most cases its your clients server where you upload your codes after they have passed the QA checks of both local-server and staging-server.
One related aspect of staged development is that in most cases they involve using SVN server for version control. Using SVN, though you can automatically update your server files from SVN server through “svn update” command but if the config file is not configured to take the different servers into consideration you will have to update the config file every time you do update on a server or set separate config file on each server and add the file to ignor list of the SVN repository.
Our way of doing it is to use a single config file and make it lookup the host address to determine which configuration settings to use. If you are familiar with codeigniter then you already know you will find your config file at system/application/config/config.php.
Find the following line in the config.php file:
Replace the line with the following lines -
Now all your URL’s will be adjusted based on the server the site is accessed from. Next we will modify the database.php file which is also located in system/application/config/database.php
Find the following line(s) in the database.php file:
Replace the above line with the following once:
The above code will give the server specific database configuration to the application based on the server it is accessed from.
Now save these two files and test your application you should be able to use the same config.php file in different servers if they are properly configured on config.php and database.php
For any further query feel free to leave a comment I will try my best to help you out.
take care,
thephpx
Aug 6th
On my endeavor to find the perfect SCRUM project management tool I came across a freeware option named “Sprintometer”. It is not entirely free as it sounds but the options it gives to a manager for free is quite outstanding. The application can be downloaded from their website { sprintometer.com } for free.
Sprintometer support project mangement in both XP and SCRUM methodology. Once you create a project it first of all asks the way the project is going to be managed. Then onward a product backlog can be prepared with stories and tasks assigned to it. Each task then can be assigned to a developer or a coder or a tester.
On the basis of the project specification the application itself generated some very useful charts that give the manager a good understanding about where the project is actually heading. Some of these charts are -
From a project manger perspective it gives me a complete hold on where my project is heading. But the only thing it lacks is integration of team members to give their inputs directly to the system. Hope they are working on it and will be made available to the freeware version in near future :p
take care,
- thephpx
Aug 2nd
Most of today’s site uses PNG images due to use of transparencies. While they give a fine solution to the transparency problem with finer edge but it also brings about page load time issues.
To solve this problem i recently came across a PNG file compression utility. This tiny utility is hosted on Source Forge and can be downloaded from here. This utility claims to have compressed PNG files upto 50%.
Though the utility is somewhat crude and runs in command prompt but there is a nifty post about how to call it from the windows shell.
For the shell add-on you may visit the following post.
take care,
- thephpx
Aug 1st
Hello everyone,
Every developer has there very own zen settings so do i
. Today I am going to writing about the stuffs I use while I am at development. If you have any better alternatives or suggestions to these applications please feel free to come forward
My preferred application development platform includes the following -
Local Work-Station/Laptop:
Central Repository Server Applications:
That is the whole host of applications that are involved in my development process which I find very helpful and agile. I work on two-stage development, my local workstation/laptop and then to my central repository where I host my SVN repositories and also live demos.
The two stage method has so far proven extreamly helpful, specially if you have a VPS account where you are at your will to install applications.
I hope this one helps you setup your zen environment :p.
take care,
- thephpx