• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

PHP V3.1 Documentation

You are viewing an old version of the documentation. For the latest, please go here: PHP V3.2

Configuration

This guide covers how to configure the 51Degrees Code Igniter plugin. See the installation guide for installation instructions.

To using 51Degrees Data in your CodeIgniter project a few lines of code are required that import the plugin then extract the $_51d data array. This example will welcome your site visitors with a message that changes depending on whether they are using a mobile or non-mobile device.

1. With the module installed into you CodeIgniter environment, go to your "views" directory, by default this will be in "your_website/public_files/application/views", and open the file "welcome_message.php" for editing. Towards the bottom of this page you will find the welcome message that reads "Welcome to Codeigniter".

2. To produce the custom message we will simply replace the line

<h1>Welcome to CodeIgniter! </h1> 

with

<?php
  $this->load->helper('51Degrees.mobi');
  $_51d = fiftyone_degrees_Detect(); 
  if($_51d['IsMobile'] == 'True') { 
    echo '<h1>Welcome Mobile Visitor </h1>'; 
  } 
  else { 
    echo '<h1>Welcome non-mobile visitor </h1>'; 
  }
?>

With this piece of code you have a simple dynamic welcome message for your visitors.

This is example is an extremely simple example of what can be done use 51Degrees Device Detector. To see how to get more data from the $_51d array see Using the Detector.