06-20-2008, 06:55 PM
|
#1 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Variable class names
I'm building a module system into something I'm coding right now, and in determining the best way to build a menu based off what modules/plugins are available I came across something I'm not sure if I can do or not.
Right now I have a very simple stopgap in that uses GET information to determine what module to load and the module takes care of the view and controller. The problem is I have the sidebar navigation menu hardcoded, and I want to make this dynamic. My first idea was to build a database of what modules were available (simply by running a check to see what files were in the module directory and running checks against them to determine that they fit the program), then after running through this list I would have a static displayMenu() method in each of these modules that could be called to build the menu.
The problem I ran into is calling these methods dynamically, assuming that the super class has no idea what their names are. I wrote a quick three second test to see if I could assign their names to a variable and call them via that;
PHP Code:
class static_var_test {
public static function displayMenu () { echo "worked"; } }
$var = 'static_var_test';
$var::displayMenu();
...very basic, just to see if I could do something like this, but apparently not. Suggestions?
-m
|
|
|
|