Re: Calling parent function with call_user_func_array
| From: | Tommy Baggett | Date: | Sat, 01 Dec 2007 02:22:21 +0000 |
| Subject: | Re: Calling parent function with call_user_func_array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265336@lists.php.net to get a copy of this message | ||
Thanks for the great advice! That did the trick and made me realize an even simpler solution to my needs in the process.
I needed to iterate the pages in reverse to store the page ID of the last <li> element of each <ul> element before allowing the walker class to do its work. This allowed me to assign a CSS class to the stored elements in the Walker class's start_el function.
Both you guys have a great weekend and thanks for the help.
On Nov 29, 2007, at 6:56 PM, Nathan Nobbe wrote:
wow; i was just looking at the wordpress source; not the prettiest code ive ever seen.. anyway; in what context do you intend to use the subclass? why dont you just create a proxy instead? eg. (php4) class WalkerProxy {var $walkerInstance = null;/** * constructor * accept an existing walker instance or create one from scratch */ function WalkerProxy($existingWalker=null) { if(!is_null($existingWalker) && is_a($existingWalker, 'Walker') { $this->walkerInstance = $existingWalker; } else { $this->walkerInstance = new Walker(); } }/** * walk * do custom WalkerProxy stuff then invoke the underlying Walker'swalk() method*/ function walk($elements, $to_depth) { //// do something custom here return $this->walkerInstance($elements, $to_depth); }/// ..... } -nathan