From b092665a78e8ee82757b51f03ab496ea0aac569a Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 7 Aug 2017 08:50:49 +0200 Subject: [PATCH] Add _p.web_url variable in twig template BT#13169 --- main/inc/lib/api.lib.php | 12 ++++++++++++ main/inc/lib/template.lib.php | 1 + 2 files changed, 13 insertions(+) diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 6168c8711c..e72d17e1c5 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -8186,3 +8186,15 @@ function location($url, $exit = true) exit; } } + +/** + * @return string + */ +function api_get_web_url() +{ + if (api_get_setting('server_type') == 'test') { + return api_get_path(WEB_PATH).'web/app_dev.php/'; + } else { + return api_get_path(WEB_PATH).'web/'; + } +} diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index f5a7a1a08e..7a6d7e4fea 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -530,6 +530,7 @@ class Template { return [ 'web' => api_get_path(WEB_PATH), + 'web_url' => api_get_web_url(), 'web_relative' => api_get_path(REL_PATH), 'web_course' => api_get_path(WEB_COURSE_PATH), 'web_main' => api_get_path(WEB_CODE_PATH),