| Latest |Kites |Pictures |Programming |Life |
![]() [filed under Programming]Zend Framework Menus Navigation ![]() Tags: Zend Framework, menus, controller, action, navigation, template, menu.phtml, This is how to put menu logic in your web page. OK, from the get go, this is hard. You may need to read it a couple of times or do more research. What we want is a web page with a menu system (a list of items) on the left of the page. The menu will be different for each controller and action. What usually happens in ZF is the ApplicationController class is created and the method indexAction is called. indexAction then uses the model to get data and passes info to the view (for example using $this->view->data = 99; ). The view is then rendered as a string, which is appended to the Layout content. It took me a while to figure that out. To make the menu we need a seperate controller, the MenuController will decide what to show on the menu. The the menu view will render it and we capture the output of the view into a layout variable. The menu HTML is used later in the layout.phtml template. In our application controller we push the "menu" onto the actionStack which makes ZF run MenuController::applicationAction next.
MenuController.php The MenuController changes the layout response segment to 'menu', all the HTML in the menu view is saved to this variable. This HTML to make the menu is then merged into the web page in layout.phtml. More notes on Zend Framework Menu Navigation. ![]() [filed under Programming]Zend Framework actionStack ![]() Further notes on Zend Framework Menu Navigation This is how you pass variables to another action on the actionStack: $this->_helper->actionStack('application', 'menu', 'default', array('show_menu'=>$this->getRequest()->action)); Then in your menu controller, ApplicationController::menuAction you can: $show_menu = $this->_getParam( 'show_menu' ); Then you can use this variable to highlight the correct menu item, e.g: <ul>
![]() [filed under Programming]youtube ![]() best youtube comment so far: JESUS IM COMING ![]() [filed under Programming]AS3 sprintf ![]() Tags: Actionscript flash AS3 flex adobe print format number format date string format float ![]() [filed under Programming]Zend Framework MySQL Out Of Memory Error ![]() Tags: Zend framework, ZF, PHP, MySQL, MySQLi, PDO, SQL, FORMAT, LONGTEXT, FLOAT, floating point, out of memory error There is a bug in the MySQLi (Note the i) adapter that causes FORMAT() to fail. For more info see the Zend DB email list. Here is the ZF DB MySQLi bug report. Hope that helps someone out :-) it's one of the obscure little bugs that are hard to pin down. ![]() [filed under Programming]shotgun blast of functions ![]() Start a side project. <-- This is quite amusing and informative. There is a classic quote:
Haha! Man-o-man. So true. It is impossible to find any related functions. Anyway, we're getting namespaces in PHP6, wow, welcome to the 90s, man. ![]() [filed under Programming]Python memory leak detector ![]() Tags: Python, memory leak, leek, object, garbage collection, garbage collector, __del__, inspect, gc, DEBUG_LEAK I have a nasty memory leak in my Python script which I can't find. For some random projects my script gobbles up 2gig of memory then quietly dies. Here is my first attempt at cobbling together a leak detector: import gc When run it outputs: Collecting GARBAGE: As you can see it tries to figure out where the object is defined in your code. This should give you some clues as to where the leak is happening. If you are still having problems try adding some debug comments to the classes as you create them, print the debug info in the dump_garbage() function. This is based on this python memory leak detector at active state. I am learning all this as I go. I guess outputing this as a .csv would help. If you have any comments or improvements drop me a line in the comments below and I'll update the code. These are some links and stuff to help you get started hunting down your memory leak:
Update: A simple urllib2 memory leak test. ![]() [filed under Programming]Python chain methods ![]() I don't know why I didn't know this, but you can chain methods in Python. I use this quite a bit in PHP and Zend Framework uses it a little. But here it is in Python: class table_model: >>> That's it. Job done. ![]() [filed under Programming]MySQL max of two columns ![]() How to get the MAX or MIN value of two columns: GREATEST( col_1, col_2 ) Or a more interesting example. I have a client who may have some reports. I need to list the clients in 'most recently active' order. So if they have had a recent action they should be near the top of the list, or if they have recently had a report they should be near the top of the list: SELECT clients.id, clients.name, clients.date, MAX(r.date), GREATEST(clients.date, IFNULL(MAX(r.date), clients.date)) AS date So this uses MAX to get the most recent report (this may return NULL if they have no reports) then I use GREATEST to choose the most recent of the two dates (two columns). Job done.
![]() [filed under Programming]since I put ![]() Google analytics, page views from Feb 2007 to July 31 2008: 2,405,706
|
| Server Grind [0.3144 seconds] |