{"id":86,"date":"2009-10-28T07:14:46","date_gmt":"2009-10-28T15:14:46","guid":{"rendered":"http:\/\/blog.portnumber53.com\/?p=86"},"modified":"2009-10-28T07:14:46","modified_gmt":"2009-10-28T15:14:46","slug":"creating-a-content-controller-using-kohana-v3-0","status":"publish","type":"post","link":"https:\/\/blog.portnumber53.com\/index.php\/2009\/10\/28\/creating-a-content-controller-using-kohana-v3-0\/","title":{"rendered":"Creating a content controller using Kohana v3.0"},"content":{"rendered":"<p>These are the things I needed to change on <strong>.httacess<\/strong> to have kohana default files working before creating my first controller:<\/p>\n<blockquote>\n<pre class=\"brush:plain\"><span style=\"color: #339966;\"><strong>\u00a0<\/strong><\/span># Turn on URL rewriting\nRewriteEngine On\n\n# Installation directory\nRewriteBase \/<span style=\"text-decoration: line-through;\"><span style=\"color: #ff0000;\">kohana\/<\/span><\/span>\n\n# Protect hidden files from being viewed\n&lt;Files .*&gt;\n Order Deny,Allow\n Deny From All\n&lt;\/Files&gt;\n\n# Protect application and system files from being viewed\nRewriteRule ^(?:application|modules|system)b - [F,L]\n\n# Allow any files or directories that exist to be displayed directly\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\n\n# Rewrite all other URLs to index.php\/URL\nRewriteRule .* index.php\/$0 [PT]<\/pre>\n<\/blockquote>\n<p>My Kohana v3 installation is not inside a folder, so I&#8217;m changing &#8220;\/<span style=\"color: #ff0000;\"><span style=\"text-decoration: line-through;\">kohana\/<\/span><\/span>&#8221; to &#8220;<span style=\"color: #339966;\">\/<\/span>&#8220;.<\/p>\n<p>I want to use my Content controller to show content for the front page and any other content pages read from the database, so I am doing the following changes to my \/application\/bootstrap file:<\/p>\n<blockquote>\n<pre class=\"brush:php\"><span style=\"color: #808080;\">Route::set('default', '(&lt;controller&gt;(\/&lt;action&gt;(\/&lt;id&gt;)))')\n -&gt;defaults(array(\n 'controller' =&gt; '<span style=\"color: #339966;\"><strong>content<\/strong><\/span>',\n 'action'\u00a0\u00a0\u00a0\u00a0 =&gt; 'index',\n ));<\/span><\/pre>\n<\/blockquote>\n<p>Create the Content controller file \/application\/classes\/controller\/content.php<\/p>\n<blockquote>\n<pre class=\"brush:php\"><span style=\"color: #339966;\">&lt;?php defined('SYSPATH') or die('No direct script access.');\n\nclass Controller_Content extends Controller {\n\n public function action_index()\n {\n $this-&gt;request-&gt;response = 'This is the content controller!';\n }\n\n public function action_view()\n {\n $this-&gt;request-&gt;response = 'This is the content controller [view action]!';\n }\n\n} \/\/ End Welcome<\/span><\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>These are the things I needed to change on .httacess to have kohana default files working before creating my first controller: \u00a0# Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase \/kohana\/ # Protect hidden files from being viewed &lt;Files .*&gt; Order Deny,Allow Deny From All &lt;\/Files&gt; # Protect&#8230; <a class=\"continue-reading-link\" href=\"https:\/\/blog.portnumber53.com\/index.php\/2009\/10\/28\/creating-a-content-controller-using-kohana-v3-0\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[88,209,212,345],"class_list":["post-86","post","type-post","status-publish","format-standard","hentry","category-kohana","tag-controller","tag-kohanav3","tag-learn","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":0,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.portnumber53.com\/index.php\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}