Skip to content

Commit

Permalink
devMode global varibale
Browse files Browse the repository at this point in the history
Resolves #4038
  • Loading branch information
brandonkelly committed Mar 25, 2019
1 parent a24d0db commit b4eb782
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added
- Added the `verifyEmailSuccessPath` config setting.
- Added the “Max Length” setting for URL fields. ([#4019](https://github.com/craftcms/cms/issues/4019))
- Added the `devMode` global Twig variable. ([#4038](https://github.com/craftcms/cms/issues/4038))
- Added `craft\config\GeneralConfig::getVerifyEmailSuccessPath()`.

### Changed
Expand Down
10 changes: 10 additions & 0 deletions docs/dev/global-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ The currently-logged-in user, represented by a <api:craft\elements\User> object,
{% endif %}
```

## `devMode`

Whether the <config:devMode> config setting is currently enabled.

```twig
{% if devMode %}
Craft is running in dev mode.
{% endif %}
```

## `loginUrl`

The URL to your site’s login page, based on the <config:loginPath> config setting.
Expand Down
2 changes: 1 addition & 1 deletion src/templates/_layouts/cp.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
{% block body %}
<div id="global-container">
<header id="global-sidebar" class="sidebar">
{% if currentUser.admin and craft.app.config.general.devMode %}
{% if currentUser.admin and devMode %}
<div id="devmode" title="{{ 'Craft CMS is running in Dev Mode.'|t('app') }}"></div>
{% endif %}

Expand Down
1 change: 1 addition & 0 deletions src/web/twig/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,7 @@ public function getGlobals(): array
$globals = [
'view' => $this->view,

'devMode' => YII_DEBUG,
'SORT_ASC' => SORT_ASC,
'SORT_DESC' => SORT_DESC,
'SORT_REGULAR' => SORT_REGULAR,
Expand Down

0 comments on commit b4eb782

Please sign in to comment.