Skip to content

Commit

Permalink
Only register Asset Bundle when necessary. #12
Browse files Browse the repository at this point in the history
  • Loading branch information
internetztube committed Feb 2, 2021
1 parent 792033f commit 5aa55e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Slug Equals Title Changelog
All notable changes to this project will be documented in this file.

## 1.3.1 - 2021-02-02
### Fixed
- Only register Asset Bundle when necessary. #12

## 1.3.0 - 2021-01-04
### Added
- Added support for Commerce Products and Categories.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "internetztube/craft-slug-equals-title",
"description": "This plugin makes sure that the slug is always the same as the title.",
"type": "craft-plugin",
"version": "1.3.0",
"version": "1.3.1",
"keywords": [
"craft",
"cms",
Expand Down
5 changes: 1 addition & 4 deletions src/SlugEqualsTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public function init()
$this->hasCpSettings = true;
self::$plugin = $this;

if (Craft::$app->request->isCpRequest) {
Craft::$app->view->registerAssetBundle(ExcludeFromRewriteAssetBundle::class);
}

$this->setComponents([
'elementStatus' => ElementStatusService::class,
]);
Expand Down Expand Up @@ -68,6 +64,7 @@ public function init()

Event::on(View::class, View::EVENT_BEFORE_RENDER_PAGE_TEMPLATE, function ($event) {
if (!$this->elementStatus->isTemplateEnabledForOverwrite($event->template)) return;
Craft::$app->view->registerAssetBundle(ExcludeFromRewriteAssetBundle::class);
/** @var View $view */
$view = $event->sender;
$element = $this->elementStatus->getElementFromEventVariables($event->variables);
Expand Down

0 comments on commit 5aa55e9

Please sign in to comment.