Description:
I have created a custom preference page on Unsubscribe link
Created a new theme for the landing page using page.html.twig.
Upload this theme in mautic.
Go to the landing page and select this theme and set it as a preference center page.
Then go to the Emails and from the dropdown in “Preference center page” select this landing page.
Select “YES” for “Show contact preference settings” and “YES” for “Show contact segment preferences” in the Email Setting.
Send an e-mail to a test segment and click on Unsubscribe link from the mailbox.
Issue:
It always shows the Standard Preference Design Page. It doesn’t show the custom Preference Page. I want to show custom contact segment preferences.
Also, try it by updating mautic to the 3.3.3 version but still not successful.
I have read many posts regarding this issue but cannot find any solution. Is it a bug or something that I am missing here?
Thanks,
Looking for the solution for this issue. If somebody can help, it will be great.
Same issue here, it seems there is a bug reported already:
opened 10:04PM - 08 Mar 21 UTC
T1
bug
landing-pages
[//]: # ( Invisible comment:
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII… I
Before you create the issue:
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
Search for similar report among other reported issues.
Learn how to troubleshoot at https://www.mautic.org/docs/en/tips/troubleshooting.html
Use drag&drop to attach images or other files )
## Bug Description
I setup a custom preference center landing page. It is published with a template in code mode and is in language fr. I send an email where I have assigned this preference center landing page to it. The email is in language fr and is using the template blank. When I click on the unsubscribe link. I see the template of my landing page encapsulated in the `message.html.twig` extends the `base.html.twig` templates of the blank template. Moreover, a custom body and html header tags are added to the template.
The generated HTML :
```html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" type="text/css" />
<script data-source="mautic">
...
</script>
</head>
<body>
<div>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<body>
my preference center landing page code mode content
</body>
</html>
</body>
</html>
```
I should be able to have a custom template for my custom landing page which is not linked to the template of the email I access the page from and without any modification done by mautic.
| Q | A
| --- | ---
| Mautic version | 3.3.1
| PHP version | 7.3.27
| Browser | Chrome
### Steps to reproduce
1. Setup a custom preference center page with template in code mode
2. Send an email with template blank and the previous preference center page assigned to this email
3. Click on the unsubscribe link in the email
### Log errors
No errors
I have tracked it here :
In [PublicControllerL242](https://github.com/mautic/mautic/blob/37ed5ee87900522c888b09ed3857ad0452fb33df/app/bundles/EmailBundle/Controller/PublicController.php#L242) :
```php
$event = new PageDisplayEvent($html, $prefCenter, $params);
$this->get('event_dispatcher')->dispatch(PageEvents::PAGE_ON_DISPLAY, $event);
$html = $event->getContent();
```
Listeners on this event are modifying the custom code of the preference center landing page. This is not the most troublesome part. It could stay as it is. However, the fact that it reuses the email template when we are in `mautic as code` template mode for the preference center is troublesome :
```php
// here $template is the one from the email from which we clicked on the unsubscribe link.
$contentTemplate = $this->factory->getHelper('theme')->checkForTwigTemplate(':'.$template.':message.html.php');
///...
$viewParams = [
'email' => $email,
'lead' => $lead,
'template' => $template,
'message' => $message,
];
return $this->render($contentTemplate, $viewParams);
```
I can propose a PR if you point me in the correct direction you would like this behavior to be changed/fixed. Maybe something like if custom preference center page is enabled and is a `mautic_as_code` template, override `$contentTemplate` to use a dedicated `empty.html.twig` template which just print `{{ message|raw }}`.
[//]: # ( Invisible comment:
Please check for related errors in the latest log file in [mautic root]/app/log/ and/or the web server's logs and post them here. Be sure to remove sensitive information if applicable. )
<bountysource-plugin>
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/96997532-mautic-is-changing-my-custom-preference-center-page-based-on-the-email-template?utm_campaign=plugin&utm_content=tracker%2F5355074&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F5355074&utm_medium=issues&utm_source=github).
</bountysource-plugin>
always using the same preference center page