diff --git a/content/underskriftskampanje/medisinsk-cannabis-pa-resept/metadata.ini b/content/underskriftskampanje/medisinsk-cannabis-pa-resept/metadata.ini index 4e11143..31e768b 100644 --- a/content/underskriftskampanje/medisinsk-cannabis-pa-resept/metadata.ini +++ b/content/underskriftskampanje/medisinsk-cannabis-pa-resept/metadata.ini @@ -2,6 +2,7 @@ date = "2026-01-15" plugins = "petition-form" thank_you_page = "takk" hide_list = true +newsletter_list_uuids = "dfcf73f4-c86a-43a1-9ddb-31309f7392a9,c4849164-d5e7-4aca-9721-423282773fa1" title = "Underskriftskampanje: Ja til medisinsk cannabis på resept!" [en] diff --git a/custom/listmonk-config.example.php b/custom/listmonk-config.example.php index fc4c3c3..f3729b1 100644 --- a/custom/listmonk-config.example.php +++ b/custom/listmonk-config.example.php @@ -9,7 +9,7 @@ return [ 'enabled' => true, 'url' => 'https://newsletter.example.com', // Your Listmonk URL (no trailing slash) - 'list_uuids' => [ + 'list_uuids' => [ // Default lists (used when no per-form UUIDs are specified) 'UUID1', 'UUID2' ] diff --git a/custom/plugins/page/newsletter-signup.php b/custom/plugins/page/newsletter-signup.php index ebd69c3..1b4e688 100644 --- a/custom/plugins/page/newsletter-signup.php +++ b/custom/plugins/page/newsletter-signup.php @@ -12,6 +12,7 @@ * Then in your PHP content file, call the function with your custom text and theme: * * + * * * Available themes: * - 'hero': Full-width gradient background section (like CTA sections) @@ -57,7 +58,7 @@ function newsletterT(string $key): string { /** * Subscribe to newsletter via Listmonk public API */ -function newsletterSubscribe(string $email, string $name): array { +function newsletterSubscribe(string $email, string $name, array $listUuids = []): array { $configPath = dirname(__DIR__, 2) . '/listmonk-config.php'; if (!file_exists($configPath)) { return ['success' => false, 'error' => 'config_missing']; @@ -71,7 +72,7 @@ function newsletterSubscribe(string $email, string $name): array { $payload = json_encode([ 'email' => $email, 'name' => $name, - 'list_uuids' => $config['list_uuids'] + 'list_uuids' => !empty($listUuids) ? $listUuids : $config['list_uuids'] ]); $url = $config['url'] . '/api/public/subscription'; @@ -210,12 +211,15 @@ SCRIPT; /** * Render the "hero" theme - full-width gradient background section */ -function newsletterRenderHero(string $introText, string $formId): string { +function newsletterRenderHero(string $introText, string $formId, array $listUuids = []): string { $csrfToken = $_SESSION['newsletter_csrf_token']; $nonce = bin2hex(random_bytes(8)); $escapedIntro = htmlspecialchars($introText, ENT_QUOTES, 'UTF-8'); $escapedFormId = htmlspecialchars($formId, ENT_QUOTES, 'UTF-8'); $t = newsletterGetTranslations(); + $listUuidsField = !empty($listUuids) + ? "\n" . ' ' + : ''; $html = << @@ -223,7 +227,7 @@ function newsletterRenderHero(string $introText, string $formId): string {

{$escapedIntro}

- + {$listUuidsField}