Skip to content

Commit

Permalink
feat: install Less module automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Nov 3, 2023
1 parent da75a7d commit e7b0916
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,26 @@ private function injectJavascriptSettings(string &$html): void
$html = str_replace("</head>", "$markup</head>", $html);
}

/**
* Install less module for the pagebuilder profile
*/
public function installLessModule(Page $page)
{
if ($this->wire->modules->get('Less')) return;

// less module is not installed
// if rockmigrations is installed we use it to install the less module
/** @var RockMigrations $rm */
$rm = $this->wire->modules->get('RockMigrations');
if ($rm) {
$rm->installModule("Less", "https://github.com/ryancramerdesign/Less/archive/refs/heads/main.zip");
return $this->renderLayout($page);
}

// rockmigrations not installed, show info to install less manually
return "<h1 style='text-align:center;padding:50px;color:red;'>Please install the Less module to use this profile!</h1>";
}

/**
* Is the given page active in the menu?
*
Expand Down
2 changes: 1 addition & 1 deletion profiles/rockpagebuilder/files/site/templates/_main.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// check if Less module is installed
// once installed you can remove this if/else and just render the layout
if ($modules->get('Less')) echo $rockfrontend->renderLayout($page);
else echo "<h1 style='text-align:center;padding:50px;color:red;'>Please install the Less module to use this profile!</h1>";
else echo $rockfrontend->installLessModule($page);
?>
</body>

Expand Down

0 comments on commit e7b0916

Please sign in to comment.