I have created a custom ModelAdmin
like this:
class CompanyAdmin extends ModelAdmin {
// private static $menu_title = 'Companies';
// private static $url_segment = 'companies';
private static $managed_models = 'Company';
private static $menu_icon = 'mysite/images/icons/company-icon.png';
}
In the above code I have commented out the static properties $menu_title
and $url_segment
because I want them to be dynamic (i.e. these properties should be dependent upon the domain name).
For this I created an extension like this:
class CompanyMenu extends LeftAndMainExtension {
public function init() {
$id = 'Company';
$title = $_SERVER["HTTP_HOST"] == "login.example.com" ? "Companies" : "Profile";
$link = $_SERVER["HTTP_HOST"] == "login.example.com" ? "admin/companies" : "admin/profile";
CMSMenu::add_menu_item($id, $title, $link);
}
}
In the _config.php
I added following code to activate the extension:
LeftAndMain::add_extension('CompanyMenu');
Problem
All this code renders the menu in the CMS correctly but:
- The icon defined in
ModelAdmin
does not come - Upon clicking Menu I get "Not Found" popup.
If I uncomment two lines in CompanyAdmin
and comment the extension code in _config.php
everything works fine.
Where am I doing wrong?