removed hard-coded page id in theme controller

theme controller class was using hard coded uuids to find and display
page data, so that's been tweaked so that is no longer needed and finds
what it needs based on what time of view is being requested

also connected it the the preview 👁️ button in the page edit screen so
page layouts based on the current theme can be seen before they are
published
This commit is contained in:
ro 2024-06-26 17:10:24 -06:00
parent ed6f028598
commit 928d5468db
No known key found for this signature in database
GPG key ID: 29B551CDBD4D3B50
3 changed files with 22 additions and 8 deletions

View file

@ -41,7 +41,7 @@ class RouteController extends Controller
case 'theme':
if ($this->member::status()) {
if (isset($second)) {
return $this->theme->getView($third);
return $this->theme->getView($third, $fourth);
} else {
return $this->theme->start();
}

View file

@ -43,7 +43,7 @@ class ThemeController extends Controller
}
}
public function getView($view = 'index')
public function getView($view = 'index', $id = null)
{
//move assets to theme testing dir
$this->assets->moveToTheme();
@ -53,11 +53,18 @@ class ThemeController extends Controller
switch ($view) {
case "index":
case "page":
$view == 'index' ?
$template = $currentTheme . '.index' :
$page;
if ($view == 'index') {
$template = $currentTheme . '.index';
$page = $this->pages->getBySlug('first');
} else {
$template = $currentTheme . '.page';
//TODO: Get rid of hard link page IDS
$page = $this->pages->getById('F791DED9-0359-4662-8976-4C474803D2C6');
//if coming from theme page, grabs id of latest page
if ($id == null) {
$id = $this->getPageID();
}
$page = $this->pages->getById($id);
}
$pageData = $this->sort->page($page);
break;
case "tags":
@ -71,7 +78,7 @@ class ThemeController extends Controller
break;
default:
$template = $currentTheme . '.index';
$page = $this->pages->getById('26245BDB-1A38-4455-80A2-7A03DE26EE33');
$page = $this->pages->getBySlug('first');
$pageData = $this->sort->page($page);
}
if ($this->member::status()) {
@ -80,4 +87,11 @@ class ThemeController extends Controller
return redirect('dashboard/start');
}
}
private function getPageID()
{
$book = $this->pages->getAll();
$page = $book->where('layout', 'page')->first();
return $page['uuid'];
}
}

View file

@ -44,7 +44,7 @@ if(isset($page['uuid']))
<svg id="option-published-icon" class="icon">
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
</svg>
</button><a href="/dashboard/page/preview/{{ $uuid }}" target="_blank"><button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page' aria-label="preview post">
</button><a href="/theme/view/page/{{ $uuid }}" target="_blank"><button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page' aria-label="preview post">
<svg id="option-preview-icon" class="icon">
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
</svg>