Skip to content

Commit

Permalink
Added the isWebRequest variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Aug 9, 2021
1 parent fc1e4ed commit 175911f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Campaign

## 1.20.3 - Unreleased
### Added
- Added the `isWebRequest` variable to campaign templates that evaluates to `true` if the campaign is being viewed via a web request using the browser URL ([#246](https://github.com/putyourlightson/craft-campaign/issues/246)).

## 1.20.2 - 2021-08-05
### Fixed
- Fixed a bug in which segments were not working with fields created in Craft 3.7.0 and above ([#241](https://github.com/putyourlightson/craft-campaign/issues/241)).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "putyourlightson/craft-campaign",
"description": "Send and manage email campaigns, contacts and mailing lists.",
"version": "1.20.2",
"version": "1.20.3",
"type": "craft-plugin",
"homepage": "https://putyourlightson.com/plugins/campaign",
"license": "proprietary",
Expand Down
6 changes: 2 additions & 4 deletions src/controllers/CampaignsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ public function actionPreviewCampaign(): Response
Craft::$app->getElements()->setPlaceholderElement($campaign);
}

$this->getView()->getTwig()->disableStrictVariables();
$this->response->data = $campaign->getHtmlBody();

return $this->renderTemplate($campaign->getCampaignType()->htmlTemplate, [
'campaign' => $campaign
]);
return $this->response;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/elements/CampaignElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ protected function route()
'browserVersionUrl' => $this->url,
'contact' => new ContactElement(),
'unsubscribeUrl' => '',
'isWebRequest' => true,
]
]
];
Expand Down Expand Up @@ -652,6 +653,7 @@ private function _getBody(string $templateType = null, ContactElement $contact =
'contact' => $contact,
'sendout' => $sendout,
'unsubscribeUrl' => $contact->getUnsubscribeUrl($sendout),
'isWebRequest' => false,
]);
}
catch (Error $exception) {
Expand Down

0 comments on commit 175911f

Please sign in to comment.