On Sep 12, 2007, at 10:58 AM, Thomas Dalton wrote:
On 12/09/2007, Jim Hu jimhu@tamu.edu wrote:
I agree that the CategoryPage class could use some hooks. In the absence of hooks, you can also make your own CategoryPage class that exends CategoryPage and overrides (there's a technical term for this, but I forget what it is) just the methods you want to hook into.
Overloading.
Thanks! I knew it was "over"-something.
But wouldn't that require rewriting the code that calls CategoryPage to make it call the new class? If you're changing the core code like that, you may as well just add the code directly to CategoryPage.php and not worry about hooks.
There is a hook.
$wgHooks['CategoryPageView'][] = 'wfMyAlternativeCategoryPage';
When I did this for SplitCategoryPage.php, it worked, except that I never did figure out how to get CategoryPage.php to autoload the Article class (I assume this means I'm doing something incorrectly). I had to add require_once('Article.php') to CategoryPage.php. Not surprisingly, I forget about this and it breaks every time I upgrade.
If it extends Article (even indirectly, via CategoryPage), it should have all the methods and attributes from the Article class already... that's the whole point of inheritance...
Yup. And it does. But it has to load the parent classes first. Which it should do via autoloading in php 5.x. I'm getting inheritance. I'm not getting autoloading. I have no idea why, since I assume that the autoloader should have run earlier. But looking at it, I can put the require in the extension, so I can take care of the upgrade problem at least.
Jim
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
===================================== Jim Hu Associate Professor Dept. of Biochemistry and Biophysics 2128 TAMU Texas A&M Univ. College Station, TX 77843-2128 979-862-4054