diff options
Diffstat (limited to 'user_guide_src/source/general')
-rw-r--r-- | user_guide_src/source/general/controllers.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/general/helpers.rst | 37 | ||||
-rw-r--r-- | user_guide_src/source/general/index.rst | 3 | ||||
-rw-r--r-- | user_guide_src/source/general/models.rst | 6 | ||||
-rw-r--r-- | user_guide_src/source/general/security.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/general/urls.rst | 11 | ||||
-rw-r--r-- | user_guide_src/source/general/views.rst | 28 |
7 files changed, 48 insertions, 50 deletions
diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst index c3c19cc62..6e5079419 100644 --- a/user_guide_src/source/general/controllers.rst +++ b/user_guide_src/source/general/controllers.rst @@ -10,8 +10,8 @@ HTTP requests should be handled. What is a Controller? ===================== -A Controller is simply a class file that is named in a way that can be -associated with a URI. +**A Controller is simply a class file that is named in a way that can be +associated with a URI.** Consider this URI:: @@ -136,7 +136,7 @@ Defining a Default Controller CodeIgniter can be told to load a default controller when a URI is not 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 +To specify a default controller, open your **application/config/routes.php** file and set this variable:: $route['default_controller'] = 'Blog'; @@ -199,8 +199,7 @@ Processing Output CodeIgniter has an output class that takes care of sending your final rendered data to the web browser automatically. More information on this -can be found in the :doc::doc:`Views <views>` and `Output -class <../libraries/output>` pages. In some cases, however, you +can be found in the :doc:`Views <views>` and :doc:`Output class <../libraries/output>` pages. In some cases, however, you might want to post-process the finalized data in some way and send it to the browser yourself. CodeIgniter permits you to add a function named _output() to your controller that will receive the finalized output diff --git a/user_guide_src/source/general/helpers.rst b/user_guide_src/source/general/helpers.rst index 71cb8b25a..3a98311a6 100644 --- a/user_guide_src/source/general/helpers.rst +++ b/user_guide_src/source/general/helpers.rst @@ -3,10 +3,10 @@ Helper Functions ################ Helpers, as the name suggests, help you with tasks. Each helper file is -simply a collection of functions in a particular category. There are URL -Helpers, that assist in creating links, there are Form Helpers that help -you create form elements, Text Helpers perform various text formatting -routines, Cookie Helpers set and read cookies, File Helpers help you +simply a collection of functions in a particular category. There are **URL +Helpers**, that assist in creating links, there are Form Helpers that help +you create form elements, **Text Helpers** perform various text formatting +routines, **Cookie Helpers** set and read cookies, File Helpers help you deal with files, etc. Unlike most other systems in CodeIgniter, Helpers are not written in an @@ -19,9 +19,9 @@ using a Helper is to load it. Once loaded, it becomes globally available in your :doc:`controller <../general/controllers>` and :doc:`views <../general/views>`. -Helpers are typically stored in your system/helpers, or -application/helpers directory. CodeIgniter will look first in your -application/helpers directory. If the directory does not exist or the +Helpers are typically stored in your **system/helpers**, or +**application/helpers directory**. CodeIgniter will look first in your +**application/helpers directory**. If the directory does not exist or the specified helper is not located there CI will instead look in your global system/helpers folder. @@ -32,11 +32,11 @@ Loading a helper file is quite simple using the following function:: $this->load->helper('name'); -Where name is the file name of the helper, without the .php file +Where **name** is the file name of the helper, without the .php file extension or the "helper" part. -For example, to load the URL Helper file, which is named -url_helper.php, you would do this:: +For example, to load the **URL Helper** file, which is named +**url_helper.php**, you would do this:: $this->load->helper('url'); @@ -63,9 +63,8 @@ Auto-loading Helpers If you find that you need a particular helper globally throughout your application, you can tell CodeIgniter to auto-load it during system -initialization. This is done by opening the -application/config/autoload.php file and adding the helper to the -autoload array. +initialization. This is done by opening the **application/config/autoload.php** +file and adding the helper to the autoload array. Using a Helper ============== @@ -84,8 +83,8 @@ URI to the controller/function you wish to link to. "Extending" Helpers =================== -To "extend" Helpers, create a file in your application/helpers/ folder -with an identical name to the existing Helper, but prefixed with MY\_ +To "extend" Helpers, create a file in your **application/helpers/** folder +with an identical name to the existing Helper, but prefixed with **MY\_** (this item is configurable. See below.). If all you need to do is add some functionality to an existing helper - @@ -98,8 +97,8 @@ sense. Under the hood, this gives you the ability to add to the functions a Helper provides, or to modify how the native Helper functions operate. -For example, to extend the native Array Helper you'll create a file -named application/helpers/MY_array_helper.php, and add or override +For example, to extend the native **Array Helper** you'll create a file +named **application/helpers/MY_array_helper.php**, and add or override functions:: // any_in_array() is not in the Array Helper, so it defines a new function @@ -130,11 +129,11 @@ Setting Your Own Prefix The filename prefix for "extending" Helpers is the same used to extend libraries and Core classes. To set your own prefix, open your -application/config/config.php file and look for this item:: +**application/config/config.php** file and look for this item:: $config['subclass_prefix'] = 'MY_'; -Please note that all native CodeIgniter libraries are prefixed with CI\_ +Please note that all native CodeIgniter libraries are prefixed with **CI\_** so DO NOT use that as your prefix. Now What? diff --git a/user_guide_src/source/general/index.rst b/user_guide_src/source/general/index.rst index 2bc684a1d..1335e9dd4 100644 --- a/user_guide_src/source/general/index.rst +++ b/user_guide_src/source/general/index.rst @@ -4,6 +4,7 @@ General Topics .. toctree:: :titlesonly: + :hidden: urls controllers @@ -29,4 +30,4 @@ General Topics environments alternative_php security - PHP Style Guide <styleguide>
\ No newline at end of file + PHP Style Guide <styleguide> diff --git a/user_guide_src/source/general/models.rst b/user_guide_src/source/general/models.rst index 4dd3e5765..b816f958a 100644 --- a/user_guide_src/source/general/models.rst +++ b/user_guide_src/source/general/models.rst @@ -65,7 +65,7 @@ model class might look like:: Anatomy of a Model ================== -Model classes are stored in your application/models/ folder. They can be +Model classes are stored in your **application/models/ folder**. They can be nested within sub-folders if you want this type of organization. The basic prototype for a model class is this:: @@ -78,7 +78,7 @@ The basic prototype for a model class is this:: } } -Where Model_name is the name of your class. Class names **must** have +Where **Model_name** is the name of your class. Class names **must** have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class. @@ -148,7 +148,7 @@ Auto-loading Models If you find that you need a particular model globally throughout your application, you can tell CodeIgniter to auto-load it during system initialization. This is done by opening the -application/config/autoload.php file and adding the model to the +**application/config/autoload.php** file and adding the model to the autoload array. Connecting to your Database diff --git a/user_guide_src/source/general/security.rst b/user_guide_src/source/general/security.rst index d9d5b728b..4d7a213d1 100644 --- a/user_guide_src/source/general/security.rst +++ b/user_guide_src/source/general/security.rst @@ -35,8 +35,8 @@ error reporting by setting the internal error_reporting flag to a value of 0. This disables native PHP errors from being rendered as output, which may potentially contain sensitive information. -Setting CodeIgniter's ENVIRONMENT constant in index.php to a value of -'production' will turn off these errors. In development mode, it is +Setting CodeIgniter's **ENVIRONMENT** constant in index.php to a value of +**\'production\'** will turn off these errors. In development mode, it is recommended that a value of 'development' is used. More information about differentiating between environments can be found on the :doc:`Handling Environments <environments>` page. diff --git a/user_guide_src/source/general/urls.rst b/user_guide_src/source/general/urls.rst index db1ffe565..211537675 100644 --- a/user_guide_src/source/general/urls.rst +++ b/user_guide_src/source/general/urls.rst @@ -28,8 +28,7 @@ approach, usually represent:: #. The third, and any additional segments, represent the ID and any variables that will be passed to the controller. -The :doc::doc:`URI Class <../libraries/uri>` and the `URL -Helper <../helpers/url_helper>` contain functions that make it +The :doc:`URI Class <../libraries/uri>` and the :doc:`URL Helper <../helpers/url_helper>` contain functions that make it easy to work with your URI data. In addition, your URLs can be remapped using the :doc:`URI Routing <routing>` feature for more flexibility. @@ -56,13 +55,13 @@ images, and robots.txt is treated as a request for your index.php file. Adding a URL Suffix =================== -In your config/config.php file you can specify a suffix that will be +In your **config/config.php** file you can specify a suffix that will be added to all URLs generated by CodeIgniter. For example, if a URL is this:: example.com/index.php/products/view/shoes -You can optionally add a suffix, like .html, making the page appear to +You can optionally add a suffix, like **.html,** making the page appear to be of a certain type:: example.com/index.php/products/view/shoes.html @@ -75,7 +74,7 @@ In some cases you might prefer to use query strings URLs:: index.php?c=products&m=view&id=345 CodeIgniter optionally supports this capability, which can be enabled in -your application/config.php file. If you open your config file you'll +your **application/config.php** file. If you open your config file you'll see these items:: $config['enable_query_strings'] = FALSE; @@ -88,7 +87,7 @@ active. Your controllers and functions will then be accessible using the index.php?c=controller&m=method -..note:: If you are using query strings you will have to build +.. note:: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs. diff --git a/user_guide_src/source/general/views.rst b/user_guide_src/source/general/views.rst index 7d0accafd..dc65f6c4f 100644 --- a/user_guide_src/source/general/views.rst +++ b/user_guide_src/source/general/views.rst @@ -24,7 +24,7 @@ in it:: <html> <head> - <title>My Blog</title> + <title>My Blog</title> </head> <body> <h1>Welcome to my Blog!</h1> @@ -141,7 +141,7 @@ to the array keys in your data:: <html> <head> - <title><?php echo $title;?></title> + <title><?php echo $title;?></title> </head> <body> <h1><?php echo $heading;?></h1> @@ -180,27 +180,27 @@ Now open your view file and create a loop:: <html> <head> - <title><?php echo $title;?></title> + <title><?php echo $title;?></title> </head> <body> - <h1><?php echo $heading;?></h1> - - <h3>My Todo List</h3> - - <ul> - <?php foreach ($todo_list as $item):?> - - <li><?php echo $item;?></li> + <h1><?php echo $heading;?></h1> + + <h3>My Todo List</h3> - <?php endforeach;?> - </ul> + <ul> + <?php foreach ($todo_list as $item):?> + + <li><?php echo $item;?></li> + + <?php endforeach;?> + </ul> </body> </html> .. note:: You'll notice that in the example above we are using PHP's alternative syntax. If you are not familiar with it you can read about - it `here </general/alternative_php>`. + it :doc:`here </general/alternative_php>`. Returning views as data ======================= |