Passing Parameters Between Controller and View in CodeIgniter

In this article We are going to discuss about How to create and passing the parameters between controller and views in CodeIgniter (CI). In my previous article, I have explained about How to Create a Hello World application in CodeIgniter (CI).

In my previous article, I have clearly explained How to create controllers and views. So, In this article just explain about how to passing the argument (parameters) between controllers and views in CodeIgniter (CI).

Step 1 :

Open the already created "helloworld.php" file in the folder "<root folder>/application/controllers". Add the some codes in that file. The final "helloworld.php" file contains the below codes.

<?php
class Helloworld extends CI_Controller 
{
var $text_to_display;
var $text_color;
public function __construct()
    {
    parent::__construct();
$this->text_to_display = 'World!';
$this->text_color = 'red';
  }
public function display()
{
$data['text_to_display'] = $this->text_to_display;
$data['text_color'] = $this->text_color;
$this->load->view('display_view',$data);
}
}
?>

Step 2:

Open the view file "display_view.php" file in the folder "<root folder>/application/views" and add some codes in that file. The final "display_view.php" file contains the below codes.

Hello <font color="<?php echo $text_color; ?>"><?php echo $text_to_display; ?></font>

Step 3:

Paste the below URL in the browser address bar and see the output.

http://localhost/CodeIgniter/index.php/Helloworld/display

Creating Hello World Application in CodeIgniter

In this article, we are going to discuss about How to create a Hello World application in CodeIgniter (CI). Before we start creating Hello World application in CodeIgniter (CI), we must know about Model View Controller (MVC) pattern. Because CodeIgniter (CI) follows the MVC pattern.

Step 1 : Creating Controller

Create a controller with the file name "helloworld.php" within "<root folder>/application/controllers" folder and write the following code in that file.

<?php
class Helloworld extends CI_Controller {
function display()
{
$this->load->view('display_view');
}
}
?>


Step 2 : Creating View

Create a View with the filename "display_view.php" within "<root folder>/application/views" folder and write the following code in that file.

Hello World!


Step 3: Run the Hello World application

Now run the above Hello World application by entering

"http://localhost/CodeIgniter/index.php/Helloworld/display" in the browser.

http://localhost/CodeIgniter/ --------> CodeIgniter root path
Helloworld  -------------> Controller name
display ---------> View name

Plupload - Upload multiple images in Drupal

In this tutorial we are going to discuss about How to upload multiple images at a time in Drupal. By default, in Drupal we can able to upload images one by one. By using PLUpload module, we can upload multiple images at a time with progress bar in Drupal.

Default File upload methos in Drupal:

By default we can upload multiple images one by one. When we create a default image field, simply set the "Number of values" to more than 1 to upload multiple images. However it is difficult to use. To upload images we need to follow the below steps.

  1. Select an image
  2. Click Upload
  3. Wait for a new file upload area to appear
  4. Select an image
  5. Click Upload
  6. Wait for a new file upload area to appear
  7. Repeat until done ...

Now, we are going to see how to accomplish the multiple file upload in Drupla with PLUpload.

Modules and Files need to be install :


Install and enable these two modules:
We'll now to need to upload the files for Plupload.



  • Extract the files that you just downloaded. You'll get a folder called /plupload/
  • Browse to the /sites/all/ folder in your Drupal site
  • If you don't have a /libraries/ folder here, create one
  • Upload the /plupload/ folder into your /libraries/ folder


Create a new field :

  • Go to Structure > Content types > Manage fields
  • Choose Image and then choose Plupload as the widget
  • All of the settings will be identical to a normal image field
  • Finish creating the field
  • Go to Content > Add content and create a new content item
  • You'll see a multiple file upload area as in the image below
  • To upload images, you can either drag files into the marked space or you can click Add


  • Add all the images you want to upload
  • Click Upload


  • You'll see a small progress bar:
  • You'll see thumbnails of the images: