Before I begin to learn any new language, I generally purchase a book or two. A few months ago, I purchased the book, “Professional CodeIgniter”. This is a really good book in that I could copy/paste/tweak much of the code from the book for an application that I was working on. I learned the basics and then some (integrating Ajax, TinyMCE, etc). I highly recommend it.
Posts Tagged ‘Codeigniter’
I am fairly new to the PHP framework scene. I have been using CodeIgniter for about 3-4 months and I have found it to be quite straightforward. I have been able to develop websites quickly using an understandable structure.
When I first began defining constants with CodeIgniter, I used a method that I learned in the book, “Professional CodeIgniter
“. I placed all of my constants at the bottom of the config.php file (system/application/config/config.php).
$config['jquery_assets'] = 'assets/js/jquery/'; |
To access the configuration item in my application, I would write something like:
$this->plugin = base_url() . $this->config->item('jquery_assets') .'imgooglemaps/jquery.imGoogleMaps-0.5.js'; |
While this works fine, I really wanted to define constants in the traditional PHP way. I recently noticed a file named constants.php (system/application/config/constants.php). Here, I am able to define application constants like a traditional PHP application.
define("GAL_THUMB_MAX_W", 120); |
I think that I will use the constants.php file from now on.
I’m learning Codeigniter for a project that I am working on. I ran into a problem when I created a controller method that accepts two parameters. My problem was that I did not know how to pass multiple paremeters using Codeigniter’s anchor function. The solution was quite simple in that all I had to do is add additional uri segments to the anchor function.
The controller method takes two arguments:
class Sites extends Controller { ... function updateVersion($vId, $sId) { ... } } |
Using the anchor function, I would then call this method that passes 2 as the $vId and 3 as the $sId (/2/3):
echo anchor('members/sites/updateVersion/2/3', 'select');
Simple enough.


