Skip to content

Commit

Permalink
Merge pull request #4 from philippdaun/develop
Browse files Browse the repository at this point in the history
Fix assets auto-loading in frontend
  • Loading branch information
daun authored Jan 3, 2020
2 parents 743033a + 50a36e7 commit 9f890a5
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions Dashboard.module
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,25 @@ class Dashboard extends Process implements Module {
];

/**
* Constructor: define texts and view folders
* Module initialization
*
* We overwrite the parent::init() method with an empty method to
* disable auto-asset loading, which wo do manually in ready() once
* we're sure we're in the admin area
*/
public function init() {}

/**
* Ready: define texts and view folders
*
*/
public function __construct() {
public function ready() {
if (!$this->isAdmin()) {
return;
}

$this->modules->loadModuleFileAssets($this);

$this->installOnHomepage = false;

$this->moduleFolder = dirname($this->modules->getModuleFile($this));
Expand All @@ -69,20 +84,22 @@ class Dashboard extends Process implements Module {
];

$this->panels = new DashboardPanelArray();

// Add classname to allow styling
$this->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
$event->object->addBodyClass("$this");
});
}

/**
* Module initialization
* Check if we're in the admin area
*
*/
public function init() {
parent::init();

// Add classname to allow styling
$this->addHookAfter('AdminTheme::getExtraMarkup', function($event) {
$theme = $event->object;
$theme->addBodyClass("$this");
});
protected function isAdmin() {
$isAdminUrl = strpos($_SERVER['REQUEST_URI'], $this->config->urls->admin) === 0;
$isAdminTemplate = $this->page && $this->page->template == 'admin';
return $isAdminUrl || $isAdminTemplate;
}

/**
Expand Down

0 comments on commit 9f890a5

Please sign in to comment.