CodeIgniter: Extend HTML Helper, script_tag(); added

June 26th, 2008

Since pass to 1.5 to 1.6 from CodeIgniter, the framework I actually use, has added various functions with notable consequences.

  • img()
    Lets you create HTML tags. The first parameter contains the image source. There is data, the second the size of the heading.
  • link_tag()
    Lets you create HTML tags. This is useful for stylesheet links, as well as other links. The parameters are href, with optional rel, type, title, media and index_page. index_page is a TRUE/FALSE value that specifics if the href should have the page specified by $config['index_page'] added to the address it creates.

And more others with form related are the most useful for me. When I have seen what link_tag() does, I’ve think that how potential will be a function in HTML Helper that allows you to add JavaScript files. I started thinking that how this can be developed and what I did is open the existing helper, looked for link_tag() code and modified to add JavaScript files.

Now this function is full working and you can use to reduce the code on your tags. I recommend it because is easiest to modify anything and you don’t need to write the code.

It looks like:
Read the rest of this entry »

Share/Save

Tags: , ,

CodeIgniter: Enable $_GET

June 25th, 2008

For security reasons CodeIgniter have $_GET disabled. I personally don’t use so much but if you want to enable $_GET on your application you only need to do two simple steps.

Security: CodeIgniter User Guide

[...]
GET data is simply disallowed by CodeIgniter since the system utilizes URI segments rather than traditional URL query strings (unless you have the query string option enabled in your config file). The global GET array is unset by the Input class during system initialization.
[...]

Now, if you want to use it:

  1. Go to config.php and find $config['uri_protocol'], change to:
    $config['uri_protocol'] = "PATH_INFO";
  2. Rebuild the $_GET array on your controller:
    parse_str($_SERVER['QUERY_STRING'],$_GET);

Share/Save

Tags: , ,

CodeIgniter: mod_rewrite

June 25th, 2008

One of the common problems of CodeIgniter is the visual structure of their URLs. We usually have our applications like http://localhost/index.php/controller/function and probably it will look better if was like this http://localhost/controller/function. This common problem have a common solution, it’s very easy and depends of a Apache’s module called mod_rewrite.

First we need to know if mod_rewrite is active on Apache. The easiest way is check the configuration file called httpd.conf and search for: mod_rewrite.so. Probably we will find this line:

LoadModule rewrite_module modules/mod_rewrite.so

It is probably that this line starts with a #, with a # on a config file like this we disallow the access to the module. If starts with this char, simply, remove it and reboot the server. Now, with this line uncommented the Apache’s server will boot mod_rewrite module every time.

Now it’s time to create our configuration file where our index.php file is located. Create a textfile and rename it to .htaccess, write this:

Read the rest of this entry »

Share/Save

Tags: , , ,

Do It Yourself: Carl Martin Plexitone Clone

June 25th, 2008

I play guitar since I was 15 and these days I improved a lot on my playing and my equipment. I started with a low-cost guitar, a Squier Telecaster (a cheapest division of Fender)… a good guitar for someone who is starting playing. Three years later, now, I’ve a Fender, a Fender Telecaster Custom 62 American Vintage and a Marshall JCM 800 (one day I’ll write about this amplifier).

In this world of music we use stomp boxes, FX like distortions, overdrives, choruses, echoes, delays, tremolos, etcetera. Furthermore, we are not rich and everyday we try to get this items cheapest but with the full quality, there is a lot of brands some low-cost and others boutique and obviously, the latests sounds better. Then the people started buying the stomp boxes reproducing the schemas and ripping it equally with a cheapest price. I personally discuss on a forum called Guitarrista.org in Spanish and there is a DIY section, the last month we started cloning the Carl Martin Plexitone. The user Stratotrasto have reproduced the PCB using the schema that you can found here.

We have done the Bill of Materials for the Plexitone DIY project parting from the schema by GnognoFasciani and looks like this:

Resistors

R1 - 1k
R2 - 1M
R3 - 47k
R4 - 47k
R5 - 2k
R6 - 4,7k

Read the rest of this entry »

Share/Save

Tags: , , , , ,

Using jQuery and CodeIgniter for a AJAX Login

June 24th, 2008

One of the most problem when the people starts coding is the needed of another to see what to do. The user guide of CodeIgniter is one of the best, okay the best, I’ve ever read, but sometimes the newbies needs more. Now it’s my time and I’ll try to explain how to do a little AJAX Login.

For this we need the last jQuery, you can download it on the official jQuery website. Then, obviously, Code Igniter.

We will start with the database. It’s simple because usually I separate the user from her profile.

1
2
3
4
5
6
7
8
CREATE TABLE `users` (
  `uid` int(10) NOT NULL AUTO_INCREMENT,
  `username` varchar(16) NOT NULL,
  `password` varchar(32) NOT NULL,
  `email` varchar(128) NOT NULL,
  `time` int(10) NOT NULL,
  PRIMARY KEY  (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

In this tutorial I’ll use md5, I prefer SHA-1 but the site I developed I used md5… Using md5 or SHA-1 only takes changes when you encode/decode the password on the registration and check if are equals on login, nothing more. Then, I’ll start with the controller and the model.

Read the rest of this entry »

Share/Save

Tags: , , , , ,