Here's a class that has come in super handy for me lately. I created it for use with Kohana v3. Basically, say you have an adminstrator backend to your website and you so you have a page for blog posts and one for blog categories. Simple enough. But you wanna give your users options to filter their results so they don't have to search through hundreds or thousands of blog posts every time they wanna find a certain post. Easy enough.
But then you have the problem where the user filters the results, finds the post they want, goes to edit it, then it sends them back to the list of all posts. But whoops, they forgot they wanted to change something else in that same post. Now they have to re-filter all over again and find it. VERY ANNOYING!
So with this class you can provide it with an array of keys to keep track of over multiple page loads. It keeps every controller and actions filters seperate so that you can easily use them throughout your controllers and views. So if you want to filter by 'Author' and 'Category' then the class will look for the keys 'author' and 'category' in either $_POST or $_GET and add them to the filters. Now when the user returns to that page, all filters will still be applied. It's a big time saver!
http://coreyworrell.com/blog/article/kohana-3-filter-class
Showing posts with label kohana 3 helper. Show all posts
Showing posts with label kohana 3 helper. Show all posts
Kohana 3 Filter Class $_POST / $_GET
Posted by
anonymous
on Wednesday, December 29, 2010
Labels:
kohana 3 helper
/
Comments: (4)
Description of the producer
Kohana 3 :: 8 helpers
Posted by
anonymous
on Thursday, December 23, 2010
Labels:
kohana 3,
kohana 3 helper
/
Comments: (0)
Kohana 3 :: Kohana Date helper
Posted by
anonymous
Labels:
kohana 3,
kohana 3 helper
/
Comments: (0)
< ?php defined('SYSPATH') OR die('No direct access allowed.'); /** * Extend the Kohana Date helper */ class Date extends Kohana_Date { /** * Number of months in a year. Value will hold month name * * @static * @uses Date::hours * @return array Array from 1-12 with month names */ public static function months_with_name() { $months = Date::hours(); for ($i = 1; $i <= 12; $i++) { $timestamp = mktime(0, 0, 0, $i, 1, 2005); $months[$i] = date("M", $timestamp); } return $months; } /** * Checks whether a string is a date * * @static * @param string date * @return bool */ public static function is_date($str) { return (boolean) strtotime($str); } } // End Date
Kohana 3 :: stylesheets and scriptfiles
Posted by
anonymous
on Monday, November 1, 2010
Labels:
kohana 3,
kohana 3 helper,
kohana 3 views,
kohana framework
/
Comments: (0)
Helper
Controller
Views
<?php defined('SYSPATH') or die('No direct script access.'); // kohana tutorials :: kohanaframework.blogspot.comclass javascript { private static $files = array(); public static function add($file) { self::$files[] = $file; } public static function get() { return self::$files; } }
Controller
class Controller_Example extends Controller_Template { public function before() { javascript::add('js/jquery.js'); javascript::add('js/jquery-ui.js'); } }
Views
<html> <head> <?php foreach(javascript::get() as $javascript ?> <script type="text/javascript" src="<?= $javascript ?>"></script> <?php endforeach; ?> </head> </html>
Kohana 3 Get Netsuite Connection
Posted by
anonymous
Labels:
kohana 3,
kohana 3 helper,
kohana framework
/
Comments: (0)
Code snippet - Get Netsuite Connection on Snipplr
Get the current route in Kohana 3
Posted by
anonymous
Labels:
kohana 3,
kohana 3 helper,
kohana framework
/
Comments: (0)
$routes = Route::all();
$name = array_search($this->request->route, $routes);
Kohana Javascript Helper
Posted by
anonymous
Labels:
kohana 3,
kohana 3 helper
/
Comments: (0)
Code snippet - Kohana Javascript Helper on Snipplr