diff options
author | Joël Cox <joel@joelcox.nl> | 2011-08-27 20:21:19 +0200 |
---|---|---|
committer | Phil Sturgeon <email@philsturgeon.co.uk> | 2011-10-27 00:44:14 +0200 |
commit | 7bd6335c77cfc5fec9e7e788d45d110c1b09ffd1 (patch) | |
tree | c4bbf6c2f08df78fb0b1be5ad8f9aa58f1915b7e /user_guide | |
parent | 5cbced2f3899726241b7a3a83e47a92fb01dbf83 (diff) |
Renamed introduction to index and small code style fixes (patch by @ericbarnes).
Diffstat (limited to 'user_guide')
-rw-r--r-- | user_guide/nav/nav.js | 2 | ||||
-rw-r--r-- | user_guide/toc.html | 2 | ||||
-rw-r--r-- | user_guide/tutorial/conclusion.html | 2 | ||||
-rw-r--r-- | user_guide/tutorial/create_news_items.html | 8 | ||||
-rw-r--r-- | user_guide/tutorial/hard_coded_pages.html | 7 | ||||
-rw-r--r-- | user_guide/tutorial/index.html (renamed from user_guide/tutorial/introduction.html) | 2 | ||||
-rw-r--r-- | user_guide/tutorial/news_section.html | 29 | ||||
-rw-r--r-- | user_guide/tutorial/static_pages.html | 16 |
8 files changed, 28 insertions, 40 deletions
diff --git a/user_guide/nav/nav.js b/user_guide/nav/nav.js index b57851a6c..bc668ec27 100644 --- a/user_guide/nav/nav.js +++ b/user_guide/nav/nav.js @@ -40,7 +40,7 @@ function create_menu(basepath) '<h3>Tutorial</h3>' + '<ul>' + - '<li><a href="'+base+'tutorial/introduction.html">Introduction</a></li>' + + '<li><a href="'+base+'tutorial/index.html">Introduction</a></li>' + '<li><a href="'+base+'tutorial/static_pages.html">Static pages</a></li>' + '<li><a href="'+base+'tutorial/news_section.html">News section</a></li>' + '<li><a href="'+base+'tutorial/create_news_items.html">Create news items</a></li>' + diff --git a/user_guide/toc.html b/user_guide/toc.html index aedea4464..bd6aaf510 100644 --- a/user_guide/toc.html +++ b/user_guide/toc.html @@ -91,7 +91,7 @@ Table of Contents <h3>Tutorial</h3> <ul> - <li><a href="./tutorial/introduction.html">Introduction</a></li> + <li><a href="./tutorial/index.html">Introduction</a></li> <li><a href="./tutorial/static_pages.html">Static pages</a></li> <li><a href="./tutorial/news_section.html">News section</a></li> <li><a href="./tutorial/create_news_items.html">Create news items</a></li> diff --git a/user_guide/tutorial/conclusion.html b/user_guide/tutorial/conclusion.html index f3bdaad1d..ccf89175f 100644 --- a/user_guide/tutorial/conclusion.html +++ b/user_guide/tutorial/conclusion.html @@ -42,7 +42,7 @@ <td id="breadcrumb"> <a href="http://codeigniter.com/">CodeIgniter Home</a> › <a href="../index.html">User Guide Home</a> › -<a href="introduction.html">Tutorial</a> › +<a href="index.html">Tutorial</a> › Conclusion </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td> diff --git a/user_guide/tutorial/create_news_items.html b/user_guide/tutorial/create_news_items.html index a25917930..48c82c799 100644 --- a/user_guide/tutorial/create_news_items.html +++ b/user_guide/tutorial/create_news_items.html @@ -42,7 +42,7 @@ <td id="breadcrumb"> <a href="http://codeigniter.com/">CodeIgniter Home</a> › <a href="../index.html">User Guide Home</a> › -<a href="introduction.html">Tutorial</a> › +<a href="index.html">Tutorial</a> › Create news items </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td> @@ -90,7 +90,7 @@ Create news items <p>Go back to your news controller. You're going to do two things here, check whether the form was submitted and whether the submitted data passed the validation rules. You'll use the <a href="../libraries/form_validation.html">form validation</a> library to do this.</p> <pre> -function create() +public function create() { $this->load->helper('form'); $this->load->library('form_validation'); @@ -112,7 +112,6 @@ function create() $this->news_model->set_news(); $this->load->view('news/success'); } - } </pre> @@ -127,7 +126,7 @@ function create() <p>The only thing that remains is writing a method that writes the data to the database. You'll use the Active Record class to insert the information and use the input library to get the posted data. Open up the model created earlier and add the following:</p> <pre> -function set_news() +public function set_news() { $this->load->helper('url'); @@ -140,7 +139,6 @@ function set_news() ); return $this->db->insert('news', $data); - } </pre> diff --git a/user_guide/tutorial/hard_coded_pages.html b/user_guide/tutorial/hard_coded_pages.html index e83f1ec80..408634a78 100644 --- a/user_guide/tutorial/hard_coded_pages.html +++ b/user_guide/tutorial/hard_coded_pages.html @@ -68,7 +68,7 @@ Features <?php class Pages extends CI_Controller { - function view($page = 'home') + public function view($page = 'home') { } @@ -104,7 +104,7 @@ class Pages extends CI_Controller { <p>In order to load these pages we'll have to check whether these page actually exists. When the page does exist, we load the view for that pages, including the header and footer and display it to the user. If it doesn't, we show a "404 Page not found" error.</p> <textarea class="textarea" style="width:100%" cols="50" rows="16"> -function view($page = 'home') +public function view($page = 'home') { if ( ! file_exists('application/views/pages/' . $page . EXT)) @@ -115,9 +115,8 @@ function view($page = 'home') $data['title'] = ucfirst($page); $this->load->view('templates/header', $data); - $this->load->view('pages/' . $page); + $this->load->view('pages/'.$page); $this->load->view('templates/footer'); - } </textarea> diff --git a/user_guide/tutorial/introduction.html b/user_guide/tutorial/index.html index 78fd00b61..4f665fe0a 100644 --- a/user_guide/tutorial/introduction.html +++ b/user_guide/tutorial/index.html @@ -42,7 +42,7 @@ <td id="breadcrumb"> <a href="http://codeigniter.com/">CodeIgniter Home</a> › <a href="../index.html">User Guide Home</a> › -<a href="introduction.html">Tutorial</a> › +<a href="index.html">Tutorial</a> › Introduction </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td> diff --git a/user_guide/tutorial/news_section.html b/user_guide/tutorial/news_section.html index 191f0e1eb..b2d883184 100644 --- a/user_guide/tutorial/news_section.html +++ b/user_guide/tutorial/news_section.html @@ -42,7 +42,7 @@ <td id="breadcrumb"> <a href="http://codeigniter.com/">CodeIgniter Home</a> › <a href="../index.html">User Guide Home</a> › -<a href="introduction.html">Tutorial</a> › +<a href="index.html">Tutorial</a> › News section </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td> @@ -71,10 +71,9 @@ News section <?php class News_model extends CI_Model { - function __construct() + public function __construct() { $this->load->database(); - } } </pre> @@ -97,18 +96,16 @@ CREATE TABLE news ( <p>Now that the database and a model have been set up, you'll need a method to get all of our posts from our database. To do this, the database abstraction layer that is included with CodeIgniter — <a href="../database/active_record.html">Active Record</a> — is used. This makes it possible to write your 'queries' once and make them work on <a href="../general/requirements.html">all supported database systems</a>. Add the following code to your model.</p> <pre> -function get_news($slug = FALSE) +public function get_news($slug = FALSE) { if ($slug === FALSE) { $query = $this->db->get('news'); return $query->result_array(); - } $query = $this->db->get_where('news', array('slug' => $slug)); return $query->row_array(); - } </pre> @@ -120,27 +117,23 @@ function get_news($slug = FALSE) <pre> <?php -class News extends CI_Controller{ +class News extends CI_Controller { - function __construct() + public function __construct() { parent::__construct(); $this->load->model('news_model'); - } - function index() + public function index() { $data['news'] = $this->news_model->get_news(); - } - function view($slug) + public function view($slug) { $data['news'] = $this->news_model->get_news($slug); - } - } </pre> @@ -151,7 +144,7 @@ class News extends CI_Controller{ <p>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 the views.</p> <pre> -function index() +public function index() { $data['news'] = $this->news_model->get_news(); $data['title'] = 'News archive'; @@ -159,7 +152,6 @@ function index() $this->load->view('templates/header', $data); $this->load->view('news/index', $data); $this->load->view('templates/footer'); - } </pre> @@ -182,7 +174,7 @@ function index() <p>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 add the following lines to the file.</p> <pre> -function view($slug) +public function view($slug) { $data['news_item'] = $this->news_model->get_news($slug); @@ -196,7 +188,6 @@ function view($slug) $this->load->view('templates/header', $data); $this->load->view('news/view', $data); $this->load->view('templates/footer'); - } </pre> @@ -204,7 +195,7 @@ function view($slug) <pre> <?php -echo '<h2>' . $news_item['title'] . '</h2>'; +echo '<h2>'.$news_item['title'].'</h2>'; echo $news_item['text']; </pre> diff --git a/user_guide/tutorial/static_pages.html b/user_guide/tutorial/static_pages.html index bf52f4543..51a04c689 100644 --- a/user_guide/tutorial/static_pages.html +++ b/user_guide/tutorial/static_pages.html @@ -42,7 +42,7 @@ <td id="breadcrumb"> <a href="http://codeigniter.com/">CodeIgniter Home</a> › <a href="../index.html">User Guide Home</a> › -<a href="introduction.html">Tutorial</a> › +<a href="index.html">Tutorial</a> › Static pages </td> <td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td> @@ -79,7 +79,7 @@ As URL schemes become more complex, this may change. But for now, this is all we class Pages extends CI_Controller { - function view($page = 'home') + public function view($page = 'home') { } @@ -134,10 +134,10 @@ If you like to be particularly un-original, try "Hello World!".</p> <p>In order to load those pages, you'll have to check whether the requested page actually exists:</p> <pre> -function view($page = 'home') +public function view($page = 'home') { - if ( ! file_exists('application/views/pages/' . $page . '.php')) + if ( ! file_exists('application/views/pages/'.$page.'.php')) { // Whoops, we don't have a page for that! show_404(); @@ -146,10 +146,10 @@ function view($page = 'home') $data['title'] = ucfirst($page); // Capitalize the first letter $this->load->view('templates/header', $data); - $this->load->view('pages/' . $page, $data); + $this->load->view('pages/'.$page, $data); $this->load->view('templates/footer', $data); - -} + +} </pre> <p>Now, when the page does exist, it is loaded, including the header and footer, and displayed to the user. If the page doesn't exist, a "404 Page not found" error is shown.</p> @@ -193,7 +193,7 @@ in the pages controller? Awesome!</p> <div id="footer"> <p> -Previous Topic: <a href="introduction.html">Introduction</a> +Previous Topic: <a href="index.html">Introduction</a> · <a href="#top">Top of Page</a> · <a href="../index.html">User Guide Home</a> · |