kohana-3

Which is the best way to display 'flash messages' in kohana v3?

守給你的承諾、 提交于 2019-12-03 09:36:31
问题 I would like to know the best way to display flash messages in Kohana v3? Some tutorials or examples would be helpful. 回答1: Do you mean like Kohana 2.x's flash session variables? The latest Kohana supports get_once() which is pretty similar to the old flash session variables. $session = Session::instance(); $session->set('test', 'Hello, World!'); // The session variable is returned and removed. $test = $session->get_once('test'); 回答2: I think the get_once is a great function, but what if you

Kohana3: Different .htaccess rewritebase and kohana base_url for dev and production environment

て烟熏妆下的殇ゞ 提交于 2019-12-03 09:25:18
问题 In my bootstrap.php I have the following: if($_SERVER['SERVER_NAME'] == 'localhost') Kohana::$environment = 'development'; else Kohana::$environment = 'production'; ... switch(Kohana::$environment) { case 'development': $settings = array('base_url' => '/kohana/', 'index_file' => FALSE); break; default: $settings = array('base_url' => '/', 'index_file' => FALSE); break; } In .htaccess have this: # Installation directory RewriteBase /kohana/ This means that if I just upload my kohana

Custom Exception Handling in Kohana3

久未见 提交于 2019-12-03 08:27:27
I have a requirement to create custom exception for the exceptions generated by my app/module. I want to consolidate all the exception classes in one place and handle the exceptions in one place. I might have generic exceptions, like mentioned below, which I would like in one common place input invalid internal error (database errors, smtp errors, other failures) permission denied session error I might have specific exceptions, like mentioned below email not valid, etc. Specific exceptions might be a subclass of generic exceptions in cases, like "email not valid" could fall under "input

Kohana 3 pagination

℡╲_俬逩灬. 提交于 2019-12-03 07:50:08
I'm really lost on how pagination works in kohana 3. Is there a good example of pagination in Kohana 3 anywhere? // Get the total count of articles $count = $this ->_profil ->articles ->count_all(); // Create the pagination object $pagi = Pagination::factory(array( 'items_per_page' => 4, 'total_items' => $count, )); // Find actual articles $articles = $this->_profil ->articles ->join_categories() ->order_by('id','DESC') ->limit($pagi->items_per_page) ->offset($pagi->offset) ->find_all(); and then in the View, you just do echo $pagi; // ofc, after passing the Pagination object to view What

Apache server ignores .htaccess

依然范特西╮ 提交于 2019-12-03 06:32:50
问题 I'm trying to get a website working on my test environment, but somehow it is not working. I can load the normal index page, but when I want to access /page/test it throws an error saying the page does not exists. My log says: File does not exist: /home/page_url/www/page Which is in fact true, but it should got to my Page controller instead and load the test method. My .htaccess looks like: # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files

Kohana 3: Example of model with validation

假装没事ソ 提交于 2019-12-03 01:02:49
问题 I find examples and tutorials about models and about validation. And I places that say the validation (or most of it at least) should be in the model, which I agree with. But I can't any examples or tutorials that show how that should be done. Could anyone help me with a simple example on how that could be done? Where would you have the rules in the model? Where would the validation happen? How would the controller know if the validation passed or fail? How would the controller get error

Kohana 3 get current controller/action/arguments

爱⌒轻易说出口 提交于 2019-12-02 20:37:22
In Kohana 2 you could easily get that information like this: echo router::$controller; echo router::$method; echo router::$arguments[0-x]; Any idea how that works in Kohana 3? Thanks in advance! From inside a controller: $this->request->controller $this->request->action $this->request->param('paramname') Unlike K2 arguments in K3 are accessed via kays which you define in your routes. Take for example this url: Route::set('default', '(<controller>(/<action>(/<id>)))') ->defaults(array('controller' => 'welcome', 'action' => 'index')); To access the "id" argument you'd call $this->request->param(

Apache server ignores .htaccess

泪湿孤枕 提交于 2019-12-02 20:11:13
I'm trying to get a website working on my test environment, but somehow it is not working. I can load the normal index page, but when I want to access /page/test it throws an error saying the page does not exists. My log says: File does not exist: /home/page_url/www/page Which is in fact true, but it should got to my Page controller instead and load the test method. My .htaccess looks like: # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect hidden files from being viewed <Files .*> Order Deny,Allow Deny From All </Files> # Protect application and system

kohana3.0 how to completely delete image file?

不问归期 提交于 2019-12-02 11:24:18
问题 I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? 回答1: I have no idea about kohana, but the unlink() function

kohana3.0 how to completely delete image file?

谁说我不能喝 提交于 2019-12-02 06:05:01
I have a kohana3.0 content and files management system, and I would like to be able to completely delete images from database, and from my folder where I have uploaded them, when a user deletes an image. Now I use for image deletion: public function delete($id = NULL) { parent::delete($id); unlink($this->path); } this in the image model. But it doesn't actually delete my image at all. How can an image file be deleted in kohana 3.0? I have no idea about kohana, but the unlink() function is how files are deleted in PHP. If this isn't working, it is possible you just have a permissions problem