Skip to content

Commit

Permalink
Adding updates to themes
Browse files Browse the repository at this point in the history
  • Loading branch information
tnylea committed Jul 30, 2024
1 parent b56a9a3 commit 5f08d3a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 18 deletions.
4 changes: 1 addition & 3 deletions config/themes.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php

return [

'folder' => resource_path('views/themes'),
'folder' => resource_path('themes'),
'publish_assets' => true,
'create_tables' => true

];
2 changes: 1 addition & 1 deletion resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
@if(count($themes) < 1)
<div class="alert alert-warning">
<strong>Wuh oh!</strong>
<p>It doesn't look like you have any themes available in your theme folder located at <code><?= resource_path('views/themes'); ?></code></p>
<p>It doesn't look like you have any themes available in your theme folder located at <code><?= resource_path('themes'); ?></code></p>
</div>
@endif

Expand Down
2 changes: 1 addition & 1 deletion resources/views/options.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div class="panel">
<div class="panel-body">

@if(file_exists(config('themes.folder', resource_path('views/themes')) . '/' . $theme->folder . '/options.blade.php'))
@if(file_exists(config('themes.folder', resource_path('themes')) . '/' . $theme->folder . '/options.blade.php'))
<?php if (!defined('ACTIVE_THEME_FOLDER')) { define("ACTIVE_THEME_FOLDER", $theme->folder); } ?>
<form action="{{ route('voyager.theme.options', $theme->folder) }}" method="POST" enctype="multipart/form-data">

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ThemesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ThemesController extends Controller
private $themes_folder = '';

public function __construct(){
$this->themes_folder = config('themes.folder', resource_path('views/themes'));
$this->themes_folder = config('themes.folder', resource_path('themes'));
}

public function index(){
Expand Down
24 changes: 12 additions & 12 deletions src/ThemesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public function boot()
{
try{

dd(config('themes.folder'));
// dd(config('themes.folder'));

$this->loadViewsFrom(__DIR__.'/../resources/views', 'themes');
//$this->loadViewsFrom(config('themes.folder'), 'themes');

$theme = '';

Expand All @@ -86,17 +86,17 @@ public function boot()

view()->share('theme', $theme);

$this->themes_folder = config('themes.folder', resource_path('views/themes'));
$folder = config('themes.folder', resource_path('themes'));

$this->loadDynamicMiddleware($this->themes_folder, $theme);
$this->loadDynamicMiddleware($folder, $theme);
$this->registerThemeComponents($theme);
$this->registerThemeFolioDirectory($theme);

// Make sure we have an active theme
if (isset($theme)) {
$this->loadViewsFrom($this->themes_folder.'/'.@$theme->folder, 'theme');
$this->loadViewsFrom($folder.'/'.@$theme->folder, 'theme');
}
$this->loadViewsFrom($this->themes_folder, 'themes_folder');
//$this->loadViewsFrom($folder, 'themes_folder');

} catch(\Exception $e){
return $e->getMessage();
Expand All @@ -122,13 +122,13 @@ public function addThemeRoutes($router)
}

private function registerThemeComponents($theme){
Blade::anonymousComponentPath(resource_path('views/themes/' . $theme->folder . '/components/elements'));
Blade::anonymousComponentPath(resource_path('views/themes/' . $theme->folder . '/components'));
Blade::anonymousComponentPath(config('themes.folder') . '/' . $theme->folder . '/components/elements');
Blade::anonymousComponentPath(config('themes.folder') . '/' . $theme->folder . '/components');
}

private function registerThemeFolioDirectory($theme){
if (File::exists(resource_path('views/themes/' . $theme->folder . '/pages'))) {
Folio::path(resource_path('views/themes/' . $theme->folder . '/pages'))->middleware([
if (File::exists( config('themes.folder') . '/' . $theme->folder . '/pages')) {
Folio::path( config('themes.folder') . '/' . $theme->folder . '/pages')->middleware([
'*' => [
//
],
Expand Down Expand Up @@ -184,11 +184,11 @@ protected function ensurePermissionExist()
}
}

private function loadDynamicMiddleware($themes_folder, $theme){
private function loadDynamicMiddleware($folder, $theme){
if (empty($theme)) {
return;
}
$middleware_folder = $themes_folder . '/' . $theme->folder . '/middleware';
$middleware_folder = $folder . '/' . $theme->folder . '/middleware';
if(file_exists( $middleware_folder )){
$middleware_files = scandir($middleware_folder);
foreach($middleware_files as $middleware){
Expand Down

0 comments on commit 5f08d3a

Please sign in to comment.