You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public function loadTemplate($name)
{
$template = new \atk4\ui\Template();
$template->app = $this;
if (in_array($name[0], ['.', '/', '\\']) || strpos($name, ':\\') !== false) {
$template->load($name);
} else {
if(is_array($this->template_dir)){
foreach ($this->template_dir as $td) {
if(file_exists($td.'/'.$name)){
$template->load($td.'/'.$name);
break;
}
}
}else{
$template->load($this->template_dir.'/'.$name);
}
}
return $template;
}
user class can override this class variable as
namespace your\namespace;
class App extends \atk4\ui\App {
use \atk4\core\SessionTrait;
use \atk4\core\NameTrait;
...
public function __construct($defaults = [])
{
parent::__construct($defaults);
$this->template_dir = [
getcwd().'/../vendor/atk4/ui/template/'.$this->skin,
getcwd().'/template',
];
}
here we have defined paths from our working directory location that is "DocumentRoot/admin" and vendor is in parent directory but user can define as per their need.
The path elements sequence defined precedence here
By this way, $this->template_dir can be override in User App class with array and user can create custom templates anywhere.
The text was updated successfully, but these errors were encountered:
gowrav-vishwakarma
changed the title
custom template must be defined in vendor atk4/ui due to this
Possible Restriction Solution: custom templates must be defined in vendor atk4/ui
Dec 30, 2018
ui/src/App.php
Line 424 in fa52a36
Suggested Code is
user class can override this class variable as
here we have defined paths from our working directory location that is "DocumentRoot/admin" and vendor is in parent directory but user can define as per their need.
By this way, $this->template_dir can be override in User App class with array and user can create custom templates anywhere.
The text was updated successfully, but these errors were encountered: