Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] setup application layout to point into views folder. #94

Merged
merged 1 commit into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

$app = new Application($ROOT_DIR, $configuration);

require_once Application::$ROOT_DIR . '/router/route.php';
require_once $app::$ROOT_DIR . '/router/route.php';
bim-g marked this conversation as resolved.
Show resolved Hide resolved

$app->run();
2 changes: 1 addition & 1 deletion src/Core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function dumper($ex)
*/
public static function setLayout(string $layout)
{
self::$LAYOUT = $layout;
self::$LAYOUT = self::$ROOT_DIR.'/views/'.$layout;
}

/**
Expand Down
9 changes: 8 additions & 1 deletion src/Core/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ protected function renderLayout(string $view)
*/
private function buildAssetHead($html)
{
if(!$html){
throwException('Unable to render empty data');
}
$dom = new \DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML(
Expand Down Expand Up @@ -207,6 +210,10 @@ public function assign(string $variable, $value)
*/
public function setLayout(string $template)
{
$this->layout = $template;
$this->layout = Application::$ROOT_DIR . '/views/' . $template;
}

public function setLayoutContent(string $layout_name){
$this->layout_content = $layout_name;
}
}