summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source
diff options
context:
space:
mode:
authorTim Nolte <noltet@sekisui-spi.com>2015-06-08 18:25:34 +0200
committerTim Nolte <noltet@sekisui-spi.com>2015-06-08 18:25:34 +0200
commit89ed9fafd75e3b65a7691f1b13440bdedadf5eda (patch)
tree5dfa69c55ff48502527fcb6f4f532fb5ad6651ca /user_guide_src/source
parent2ac4177b4b6afc63d594523416c3991d23dddf20 (diff)
parentb76394834a3e36e8c376913cd9666a8d7a4cea45 (diff)
Merge branch 'develop' into feature/mysqli-ssl
Diffstat (limited to 'user_guide_src/source')
-rw-r--r--user_guide_src/source/changelog.rst12
-rw-r--r--user_guide_src/source/database/utilities.rst4
-rw-r--r--user_guide_src/source/general/controllers.rst2
-rw-r--r--user_guide_src/source/general/environments.rst4
-rw-r--r--user_guide_src/source/general/reserved_names.rst1
-rw-r--r--user_guide_src/source/helpers/date_helper.rst2
-rw-r--r--user_guide_src/source/installation/upgrade_300.rst18
-rw-r--r--user_guide_src/source/libraries/caching.rst4
-rw-r--r--user_guide_src/source/libraries/config.rst4
-rw-r--r--user_guide_src/source/libraries/file_uploading.rst4
-rw-r--r--user_guide_src/source/libraries/form_validation.rst7
-rw-r--r--user_guide_src/source/libraries/image_lib.rst10
-rw-r--r--user_guide_src/source/libraries/migration.rst6
-rw-r--r--user_guide_src/source/libraries/security.rst8
-rw-r--r--user_guide_src/source/overview/features.rst4
-rw-r--r--user_guide_src/source/tutorial/create_news_items.rst4
-rw-r--r--user_guide_src/source/tutorial/news_section.rst62
-rw-r--r--user_guide_src/source/tutorial/static_pages.rst55
18 files changed, 113 insertions, 98 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 5454638ac..7e14152e3 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -11,6 +11,10 @@ Release Date: Not Released
- Added DoS mitigation to :php:func:`hash_pbkdf2()` :doc:`compatibility function <general/compatibility_functions>`.
+- Database
+
+ - Added ``list_fields()`` support for SQLite ('sqlite3' and 'pdo_sqlite' drivers).
+
Bug fixes for 3.0.1
-------------------
@@ -19,6 +23,14 @@ Bug fixes for 3.0.1
- Fixed a bug (#3761) - :doc:`URL Helper <helpers/url_helper>` function :php:func:`anchor()` didn't work with array inputs.
- Fixed a bug (#3773) - ``db_select()`` didn't work for MySQL with the PDO :doc:`Database <database/index>` driver.
- Fixed a bug (#3771) - :doc:`Form Validation Library <libraries/form_validation>` was looking for a 'form_validation_' prefix when trying to translate field name labels.
+- Fixed a bug (#3787) - :doc:`FTP Library <libraries/ftp>` method ``delete_dir()`` failed when the target has subdirectories.
+- Fixed a bug (#3801) - :doc:`Output Library <libraries/output>` method ``_display_cache()`` incorrectly looked for the last modified time of a directory instead of the cache file.
+- Fixed a bug (#3816) - :doc:`Form Validation Library <libraries/form_validation>` treated empty string values as non-existing ones.
+- Fixed a bug (#3823) - :doc:`Session Library <libraries/sessions>` drivers Redis and Memcached didn't properly handle locks that are blocking the request for more than 30 seconds.
+- Fixed a bug (#3846) - :doc:`Image Manipulation Library <libraries/image_lib>` method `image_mirror_gd()` didn't properly initialize its variables.
+- Fixed a bug (#3854) - `field_data()` didn't work properly with the Oracle (OCI8) database driver.
+- Fixed a bug in the :doc:`Database Utility Class <database/utilities>` method ``csv_from_result()`` didn't work with a whitespace CSV delimiter.
+- Fixed a bug (#3890) - :doc:`Input Library <libraries/input>` method ``get_request_header()`` treated header names as case-sensitive.
Version 3.0.0
=============
diff --git a/user_guide_src/source/database/utilities.rst b/user_guide_src/source/database/utilities.rst
index cc4aeb018..81b949dd7 100644
--- a/user_guide_src/source/database/utilities.rst
+++ b/user_guide_src/source/database/utilities.rst
@@ -18,7 +18,7 @@ Initializing the Utility Class
Load the Utility Class as follows::
- $this->load->dbutil()
+ $this->load->dbutil();
You can also pass another database object to the DB Utility loader, in case
the database you want to manage isn't the default one::
@@ -35,7 +35,7 @@ assigning it directly to ``$this->dbutil``.
Once initialized you will access the methods using the ``$this->dbutil``
object::
- $this->dbutil->some_method()
+ $this->dbutil->some_method();
****************************
Using the Database Utilities
diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst
index bc8319dd8..7ab5a7f6a 100644
--- a/user_guide_src/source/general/controllers.rst
+++ b/user_guide_src/source/general/controllers.rst
@@ -138,7 +138,7 @@ present, as will be the case when only your site root URL is requested.
To specify a default controller, open your **application/config/routes.php**
file and set this variable::
- $route['default_controller'] = 'Blog';
+ $route['default_controller'] = 'blog';
Where Blog is the name of the controller class you want used. If you now
load your main index.php file without specifying any URI segments you'll
diff --git a/user_guide_src/source/general/environments.rst b/user_guide_src/source/general/environments.rst
index f5a4f617e..7f030b6ef 100644
--- a/user_guide_src/source/general/environments.rst
+++ b/user_guide_src/source/general/environments.rst
@@ -48,5 +48,5 @@ Configuration Files
Optionally, you can have CodeIgniter load environment-specific
configuration files. This may be useful for managing things like
differing API keys across multiple environments. This is described in
-more detail in the environment section of the :doc:`Config
-Class <../libraries/config#environments>`_ documentation. \ No newline at end of file
+more detail in the environment section of the :doc:`Config Class
+<../libraries/config>`_ documentation. \ No newline at end of file
diff --git a/user_guide_src/source/general/reserved_names.rst b/user_guide_src/source/general/reserved_names.rst
index a7b0c3465..5d745cba6 100644
--- a/user_guide_src/source/general/reserved_names.rst
+++ b/user_guide_src/source/general/reserved_names.rst
@@ -75,6 +75,7 @@ Constants
- FOPEN_READ_WRITE_CREATE
- FOPEN_WRITE_CREATE_STRICT
- FOPEN_READ_WRITE_CREATE_STRICT
+- SHOW_DEBUG_BACKTRACE
- EXIT_SUCCESS
- EXIT_ERROR
- EXIT_CONFIG
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index e0f9f0033..a85da26a4 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -400,7 +400,7 @@ UM10 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands
UM95 (UTC - 09:30) Marquesas Islands
UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
-UM7 (UTC - 11:00) Mountain Standard Time
+UM7 (UTC - 07:00) Mountain Standard Time
UM6 (UTC - 06:00) Central Standard Time
UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
UM45 (UTC - 04:30) Venezuelan Standard Time
diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst
index a3d712482..de816b6c7 100644
--- a/user_guide_src/source/installation/upgrade_300.rst
+++ b/user_guide_src/source/installation/upgrade_300.rst
@@ -8,9 +8,13 @@ Before performing an update you should take your site offline by replacing the i
Step 1: Update your CodeIgniter files
*************************************
-Replace all files and directories in your "system" folder and replace
-your index.php file. If any modifications were made to your index.php
-they will need to be made fresh in this new one.
+**Replace** all files and directories in your *system/* directory and
+replace your index.php file. If any modifications were made to your
+index.php they will need to be made fresh in this new one.
+
+.. important:: You have to delete the old *system/* directory first and
+ then put the new one in its place. A simple copy-paste may cause
+ issues.
.. note:: If you have any custom developed files in these folders please
make copies of them first.
@@ -34,12 +38,12 @@ For example, if you have the following library file:
The same goes for driver libraries and extensions and/or overrides of CodeIgniter's
own libraries and core classes.
- application/libraries/MY_email.php
+ application/libraries/MY_email.php
application/core/MY_log.php
The above files should respectively be renamed to the following:
- application/libraries/MY_Email.php
+ application/libraries/MY_Email.php
application/core/MY_Log.php
Controllers:
@@ -76,9 +80,9 @@ Step 5: Move your Log class overrides or extensions
The Log Class is considered as a "core" class and is now located in the
**system/core/** directory. Therefore, in order for your Log class overrides
-or extensions to work, you need to move them to **application/core/**::
+or extensions to work, you need to move them to **application/core/**:
- application/libraries/Log.php -> application/core/Log.php
+ application/libraries/Log.php -> application/core/Log.php
application/libraries/MY_Log.php -> application/core/MY_Log.php
*****************************************
diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst
index f54de5faf..a7081ec6b 100644
--- a/user_guide_src/source/libraries/caching.rst
+++ b/user_guide_src/source/libraries/caching.rst
@@ -18,7 +18,7 @@ requirements are not met.
Example Usage
*************
-The following example will load the cache driver, specify `APC <#apc>`_
+The following example will load the cache driver, specify `APC <#alternative-php-cache-apc-caching>`_
as the driver to use, and fall back to file-based caching if APC is not
available in the hosting environment.
@@ -66,7 +66,7 @@ Class Reference
hosting environment.
::
- if ($this->cache->apc->is_supported()
+ if ($this->cache->apc->is_supported())
{
if ($data = $this->cache->apc->get('my_cache'))
{
diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst
index 3138e3403..a45cacdf5 100644
--- a/user_guide_src/source/libraries/config.rst
+++ b/user_guide_src/source/libraries/config.rst
@@ -92,9 +92,9 @@ Fetching Config Items
To retrieve an item from your config file, use the following function::
- $this->config->item('item name');
+ $this->config->item('item_name');
-Where item name is the $config array index you want to retrieve. For
+Where item_name is the $config array index you want to retrieve. For
example, to fetch your language choice you'll do this::
$lang = $this->config->item('language');
diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst
index ea2fef7f2..6d2106be8 100644
--- a/user_guide_src/source/libraries/file_uploading.rst
+++ b/user_guide_src/source/libraries/file_uploading.rst
@@ -118,7 +118,7 @@ this code and save it to your **application/controllers/** directory::
$this->load->library('upload', $config);
- if ( ! $this->upload->do_upload())
+ if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
@@ -352,4 +352,4 @@ Class Reference
image_height Image height
image_type Image type (usually the file name extension without the period)
image_size_str A string containing the width and height (useful to put into an image tag)
- ================ ==================================================================================================== \ No newline at end of file
+ ================ ====================================================================================================
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index da43a4bec..fa50c6dcf 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -327,15 +327,15 @@ can also prep your data in various ways. For example, you can set up
rules like this::
$this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]');
- $this->form_validation->set_rules('password', 'Password', 'trim|required|md5');
+ $this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[8]');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|matches[password]');
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
In the above example, we are "trimming" the fields, checking for length
-where necessary and converting the password to MD5.
+where necessary and making sure that both password fields match.
**Any native PHP function that accepts one parameter can be used as a
-rule, like htmlspecialchars, trim, md5, etc.**
+rule, like ``htmlspecialchars()``, ``trim()``, etc.**
.. note:: You will generally want to use the prepping functions
**after** the validation rules so if there is an error, the
@@ -946,6 +946,7 @@ Rule Parameter Description
========================= ========== ============================================================================================= =======================
**required** No Returns FALSE if the form element is empty.
**matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item]
+**regex_match** Yes Returns FALSE if the form element does not match the regular expression. regex_match[/regex/]
**differs** Yes Returns FALSE if the form element does not differ from the one in the parameter. differs[form_item]
**is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field]
parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be
diff --git a/user_guide_src/source/libraries/image_lib.rst b/user_guide_src/source/libraries/image_lib.rst
index ae2c8478e..e5f7c000f 100644
--- a/user_guide_src/source/libraries/image_lib.rst
+++ b/user_guide_src/source/libraries/image_lib.rst
@@ -89,7 +89,7 @@ If they fail you can retrieve the error message using this function::
echo $this->image_lib->display_errors();
-A good practice is use the processing function conditionally, showing an
+A good practice is to use the processing function conditionally, showing an
error upon failure, like this::
if ( ! $this->image_lib->resize())
@@ -187,7 +187,7 @@ Two Types of Watermarking
There are two types of watermarking that you can use:
-- **Text**: The watermark message will be generating using text, either
+- **Text**: The watermark message will be generated using text, either
with a True Type font that you specify, or using the native text
output that the GD library supports. If you use the True Type version
your GD installation must be compiled with True Type support (most
@@ -231,7 +231,7 @@ bottom/center of the image, 20 pixels from the bottom of the image.
Watermarking Preferences
========================
-This table shown the preferences that are available for both types of
+This table shows the preferences that are available for both types of
watermarking (text or overlay)
======================= =================== ======================= ==========================================================================
@@ -264,7 +264,7 @@ Preference Default Value Options Description
Text Preferences
----------------
-This table shown the preferences that are available for the text type of
+This table shows the preferences that are available for the text type of
watermarking.
======================= =================== =================== ==========================================================================
@@ -289,7 +289,7 @@ Preference Default Value Options Description
Overlay Preferences
-------------------
-This table shown the preferences that are available for the overlay type
+This table shows the preferences that are available for the overlay type
of watermarking.
======================= =================== =================== ==========================================================================
diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst
index 25be0c93c..97c72303c 100644
--- a/user_guide_src/source/libraries/migration.rst
+++ b/user_guide_src/source/libraries/migration.rst
@@ -88,7 +88,7 @@ as *20121031100537_add_blog.php*.
}
}
-Then in **application/config/migration.php** set ``$config['migration_version'] = 1;``.
+Then in **application/config/migration.php** set ``$config['migration_version'] = 20121031100537;``.
*************
Usage Example
@@ -164,7 +164,7 @@ Class Reference
.. php:method:: latest()
- :returns: TRUE if no migrations are found, current version string on success, FALSE on failure
+ :returns: Current version string on success, FALSE on failure
:rtype: mixed
This works much the same way as ``current()`` but instead of looking for
@@ -181,4 +181,4 @@ Class Reference
specific versions. It works just like ``current()`` but ignores ``$config['migration_version']``.
::
- $this->migration->version(5); \ No newline at end of file
+ $this->migration->version(5);
diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst
index ac56fc589..305a8e57c 100644
--- a/user_guide_src/source/libraries/security.rst
+++ b/user_guide_src/source/libraries/security.rst
@@ -35,12 +35,6 @@ To filter data through the XSS filter use the ``xss_clean()`` method::
$data = $this->security->xss_clean($data);
-If you want the filter to run automatically every time it encounters
-POST or COOKIE data you can enable it by opening your
-application/config/config.php file and setting this::
-
- $config['global_xss_filtering'] = TRUE;
-
An optional second parameter, *is_image*, allows this function to be used
to test images for potential XSS attacks, useful for file upload
security. When this second parameter is set to TRUE, instead of
@@ -88,7 +82,7 @@ may alter this behavior by editing the following config parameter
::
- $config['csrf_regeneration'] = TRUE;
+ $config['csrf_regenerate'] = TRUE;
Select URIs can be whitelisted from csrf protection (for example API
endpoints expecting externally POSTed content). You can add these URIs
diff --git a/user_guide_src/source/overview/features.rst b/user_guide_src/source/overview/features.rst
index b230be9a3..f62546b61 100644
--- a/user_guide_src/source/overview/features.rst
+++ b/user_guide_src/source/overview/features.rst
@@ -8,8 +8,8 @@ how intuitively or intelligently it is designed. Features don't reveal
anything about the quality of the code, or the performance, or the
attention to detail, or security practices. The only way to really judge
an app is to try it and get to know the code.
-:doc:`Installing <../installation/>`_ CodeIgniter is child's play so we
-encourage you to do just that. In the mean time here's a list of
+:doc:`Installing <../installation/index>` CodeIgniter is child's play so
+we encourage you to do just that. In the mean time here's a list of
CodeIgniter's main features.
- Model-View-Controller Based System
diff --git a/user_guide_src/source/tutorial/create_news_items.rst b/user_guide_src/source/tutorial/create_news_items.rst
index 71d2080af..5c5270472 100644
--- a/user_guide_src/source/tutorial/create_news_items.rst
+++ b/user_guide_src/source/tutorial/create_news_items.rst
@@ -18,11 +18,11 @@ application/views/news/create.php.
::
- <h2><?php echo $title ?></h2>
+ <h2><?php echo $title; ?></h2>
<?php echo validation_errors(); ?>
- <?php echo form_open('news/create') ?>
+ <?php echo form_open('news/create'); ?>
<label for="title">Title</label>
<input type="input" name="title" /><br />
diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst
index d8ebac4a3..286d620dc 100644
--- a/user_guide_src/source/tutorial/news_section.rst
+++ b/user_guide_src/source/tutorial/news_section.rst
@@ -15,10 +15,9 @@ should be placed in a model, so they can easily be reused later. Models
are the place where you retrieve, insert, and update information in your
database or other data stores. They represent your data.
-Open up the application/models directory and create a new file called
-News_model.php and add the following code. Make sure you've configured
-your database properly as described
-:doc:`here <../database/configuration>`.
+Open up the *application/models/* directory and create a new file called
+*News_model.php* and add the following code. Make sure you've configured
+your database properly as described :doc:`here <../database/configuration>`.
::
@@ -37,8 +36,8 @@ library. This will make the database class available through the
``$this->db`` object.
Before querying the database, a database schema has to be created.
-Connect to your database and run the SQL command below. Also add some
-seed records.
+Connect to your database and run the SQL command below (MySQL).
+Also add some seed records.
::
@@ -75,7 +74,7 @@ following code to your model.
With this code you can perform two different queries. You can get all
news records, or get a news item by its `slug <#>`_. You might have
-noticed that the $slug variable wasn't sanitized before running the
+noticed that the ``$slug`` variable wasn't sanitized before running the
query; :doc:`Query Builder <../database/query_builder>` does this for you.
Display the news
@@ -83,9 +82,9 @@ Display the news
Now that the queries are written, the model should be tied to the views
that are going to display the news items to the user. This could be done
-in our pages controller created earlier, but for the sake of clarity, a
-new "news" controller is defined. Create the new controller at
-application/controllers/News.php.
+in our ``Pages`` controller created earlier, but for the sake of clarity,
+a new ``News`` controller is defined. Create the new controller at
+*application/controllers/News.php*.
::
@@ -96,6 +95,7 @@ application/controllers/News.php.
{
parent::__construct();
$this->load->model('news_model');
+ $this->load->helper('url_helper');
}
public function index()
@@ -113,11 +113,13 @@ Looking at the code, you may see some similarity with the files we
created earlier. First, the ``__construct()`` method: it calls the
constructor of its parent class (``CI_Controller``) and loads the model,
so it can be used in all other methods in this controller.
+It also loads a collection of :doc:`URL Helper <../helpers/url_helper>`
+functions, because we'll use one of them in a view later.
-Next, there are two methods to view all news items and one for a
-specific news item. You can see that the $slug variable is passed to the
-model's method in the second method. The model is using this slug to
-identify the news item to be returned.
+Next, there are two methods to view all news items and one for a specific
+news item. You can see that the ``$slug`` variable is passed to the model's
+method in the second method. The model is using this slug to identify the
+news item to be returned.
Now the data is retrieved by the controller through our model, but
nothing is displayed yet. The next thing to do is passing this data to
@@ -136,35 +138,35 @@ the views.
}
The code above gets all news records from the model and assigns it to a
-variable. The value for the title is also assigned to the $data['title']
+variable. The value for the title is also assigned to the ``$data['title']``
element and all data is passed to the views. You now need to create a
-view to render the news items. Create application/views/news/index.php
+view to render the news items. Create *application/views/news/index.php*
and add the next piece of code.
::
- <h2><?php echo $title ?></h2>
+ <h2><?php echo $title; ?></h2>
<?php foreach ($news as $news_item): ?>
- <h3><?php echo $news_item['title'] ?></h3>
+ <h3><?php echo $news_item['title']; ?></h3>
<div class="main">
- <?php echo $news_item['text'] ?>
+ <?php echo $news_item['text']; ?>
</div>
- <p><a href="<?php echo $news_item['slug'] ?>">View article</a></p>
+ <p><a href="<?php echo site_url('news/'.$news_item['slug']); ?>">View article</a></p>
- <?php endforeach ?>
+ <?php endforeach; ?>
Here, each news item is looped and displayed to the user. You can see we
-wrote our template in PHP mixed with HTML. If you prefer to use a
-template language, you can use CodeIgniter's :doc:`Template
+wrote our template in PHP mixed with HTML. If you prefer to use a template
+language, you can use CodeIgniter's :doc:`Template
Parser <../libraries/parser>` class or a third party parser.
The news overview page is now done, but a page to display individual
news items is still absent. The model created earlier is made in such
way that it can easily be used for this functionality. You only need to
add some code to the controller and create a new view. Go back to the
-news controller and update ``view()`` with the following:
+``News`` controller and update ``view()`` with the following:
::
@@ -198,12 +200,12 @@ The only things left to do is create the corresponding view at
Routing
-------
-Because of the wildcard routing rule created earlier, you need an
-extra route to view the controller that you just made. Modify your
-routing file (application/config/routes.php) so it looks as follows.
-This makes sure the requests reaches the news controller instead of
-going directly to the pages controller. The first line routes URI's with
-a slug to the view method in the news controller.
+Because of the wildcard routing rule created earlier, you need an extra
+route to view the controller that you just made. Modify your routing file
+(*application/config/routes.php*) so it looks as follows.
+This makes sure the requests reaches the ``News`` controller instead of
+going directly to the ``Pages`` controller. The first line routes URI's
+with a slug to the ``view()`` method in the ``News`` controller.
::
diff --git a/user_guide_src/source/tutorial/static_pages.rst b/user_guide_src/source/tutorial/static_pages.rst
index 62b3469ad..66621471e 100644
--- a/user_guide_src/source/tutorial/static_pages.rst
+++ b/user_guide_src/source/tutorial/static_pages.rst
@@ -37,24 +37,24 @@ code.
}
}
-You have created a class named "pages", with a view method that accepts
-one argument named $page. The pages class is extending the
-CI_Controller class. This means that the new pages class can access the
-methods and variables defined in the CI_Controller class
-(system/core/Controller.php).
+You have created a class named ``Pages``, with a view method that accepts
+one argument named ``$page``. The ``Pages`` class is extending the
+``CI_Controller`` class. This means that the new pages class can access the
+methods and variables defined in the ``CI_Controller`` class
+(*system/core/Controller.php*).
The **controller is what will become the center of every request** to
your web application. In very technical CodeIgniter discussions, it may
be referred to as the *super object*. Like any php class, you refer to
-it within your controllers as $this. Referring to $this is how you will
-load libraries, views, and generally command the framework.
+it within your controllers as ``$this``. Referring to ``$this`` is how
+you will load libraries, views, and generally command the framework.
Now you've created your first method, it's time to make some basic page
templates. We will be creating two "views" (page templates) that act as
our page footer and header.
-Create the header at application/views/templates/header.php and add the
-following code.
+Create the header at *application/views/templates/header.php* and add
+the following code:
::
@@ -64,17 +64,17 @@ following code.
</head>
<body>
- <h1><?php echo $title ?></h1>
+ <h1><?php echo $title; ?></h1>
The header contains the basic HTML code that you'll want to display
before loading the main view, together with a heading. It will also
-output the $title variable, which we'll define later in the controller.
-Now create a footer at application/views/templates/footer.php that
+output the ``$title`` variable, which we'll define later in the controller.
+Now, create a footer at *application/views/templates/footer.php* that
includes the following code:
::
- <em>&copy; 2014</em>
+ <em>&copy; 2015</em>
</body>
</html>
@@ -83,12 +83,12 @@ Adding logic to the controller
Earlier you set up a controller with a ``view()`` method. The method
accepts one parameter, which is the name of the page to be loaded. The
-static page templates will be located in the application/views/pages/
+static page templates will be located in the *application/views/pages/*
directory.
-In that directory, create two files named home.php and about.php. Within
-those files, type some text − anything you'd like − and save them. If
-you like to be particularly un-original, try "Hello World!".
+In that directory, create two files named *home.php* and *about.php*.
+Within those files, type some text − anything you'd like − and save them.
+If you like to be particularly un-original, try "Hello World!".
In order to load those pages, you'll have to check whether the requested
page actually exists:
@@ -122,20 +122,21 @@ function that renders the default error page.
In the header template, the ``$title`` variable was used to customize the
page title. The value of title is defined in this method, but instead of
assigning the value to a variable, it is assigned to the title element
-in the $data array.
+in the ``$data`` array.
The last thing that has to be done is loading the views in the order
they should be displayed. The second parameter in the ``view()`` method is
used to pass values to the view. Each value in the ``$data`` array is
assigned to a variable with the name of its key. So the value of
-``$data['title']`` in the controller is equivalent to $title in the view.
+``$data['title']`` in the controller is equivalent to ``$title`` in the
+view.
Routing
-------
The controller is now functioning! Point your browser to
-[your-site-url]index.php/pages/view to see your page. When you visit
-index.php/pages/view/about you'll see the about page, again including
+``[your-site-url]index.php/pages/view`` to see your page. When you visit
+``index.php/pages/view/about`` you'll see the about page, again including
the header and footer.
Using custom routing rules, you have the power to map any URI to any
@@ -143,8 +144,8 @@ controller and method, and break free from the normal convention:
``http://example.com/[controller-class]/[controller-method]/[arguments]``
Let's do that. Open the routing file located at
-application/config/routes.php and add the following two lines. Remove
-all other code that sets any element in the $route array.
+*application/config/routes.php* and add the following two lines.
+Remove all other code that sets any element in the ``$route`` array.
::
@@ -161,9 +162,9 @@ arguments.
More information about routing can be found in the URI Routing
:doc:`documentation <../general/routing>`.
-Here, the second rule in the $routes array matches **any** request using
-the wildcard string (:any). and passes the parameter to the ``view()``
-method of the pages class.
+Here, the second rule in the ``$routes`` array matches **any** request
+using the wildcard string ``(:any)``. and passes the parameter to the
+``view()`` method of the ``Pages`` class.
-Now visit index.php/about. Did it get routed correctly to the ``view()``
+Now visit ``index.php/about``. Did it get routed correctly to the ``view()``
method in the pages controller? Awesome!