Skip to content

Commit

Permalink
pass whole GlobalConfig to Twig templates instead of individual confi…
Browse files Browse the repository at this point in the history
…g settings
  • Loading branch information
osma committed Apr 25, 2024
1 parent ee292dc commit 80a7c9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
12 changes: 2 additions & 10 deletions src/controller/WebController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,9 @@ public function __construct($model)
$this->twig = new \Twig\Environment($loader, array('cache' => $tmpDir,'auto_reload' => true));
// used for setting the base href for the relative urls
$this->twig->addGlobal("BaseHref", $this->getBaseHref());
// setting the service name string from the config.ttl
$this->twig->addGlobal("ServiceName", $this->model->getConfig()->getServiceName());

// setting the service custom css file from the config.ttl
if ($this->model->getConfig()->getCustomCss() !== null) {
$this->twig->addGlobal("ServiceCustomCss", $this->model->getConfig()->getCustomCss());
}
// used for displaying the ui language selection as a dropdown
if ($this->model->getConfig()->getUiLanguageDropdown() !== null) {
$this->twig->addGlobal("LanguageDropdown", $this->model->getConfig()->getUiLanguageDropdown());
}
// pass the GlobalConfig object to templates so they can access configuration
$this->twig->addGlobal("GlobalConfig", $this->model->getConfig());

// setting the list of properties to be displayed in the search results
$this->twig->addGlobal("PreferredProperties", array('skos:prefLabel', 'skos:narrower', 'skos:broader', 'skosmos:memberOf', 'skos:altLabel', 'skos:related'));
Expand Down
6 changes: 3 additions & 3 deletions src/view/base-template.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<link href="resource/fontawesome/css/fontawesome.css" rel="stylesheet">
<link href="resource/fontawesome/css/solid.css" rel="stylesheet">
<link href="resource/fontawesome/css/regular.css" rel="stylesheet">
{% if ServiceCustomCss %}
<link href="{{ ServiceCustomCss }}" media="screen, print" rel="stylesheet" type="text/css">
{% if GlobalConfig.customCss %}
<link href="{{ GlobalConfig.customCss }}" media="screen, print" rel="stylesheet" type="text/css">
{% endif %}
{% for plugin, files in request.plugins.pluginsCSS %}{% for file in files %}<link href="{{ file }}" media="screen, print" rel="stylesheet" type="text/css">{% endfor %}{% endfor %}
<title>{{ ServiceName }}{% block title %}{% endblock %}</title>
<title>{{ GlobalConfig.serviceName }}{% block title %}{% endblock %}</title>
</head>
<body{% if request.vocabid == '' and request.page != 'feedback' and request.page != 'about' and request.page != 'search' %} class="bg-light frontpage-logo"{% else %} class="bg-medium vocab-{{ request.vocabid }}"{% endif %}>
<header>
Expand Down

0 comments on commit 80a7c9e

Please sign in to comment.