subscribe_by_code

NAML documentation   Watch a video
   Usages of this macro
... in subscribe_by_code.naml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<override_macro name="subscribe_by_code" requires="servlet">
    <n.node_page
Macro
Requires: servlet
Parameters: do
.>
        <n.catch_exception
Binary
Namespace: BasicNamespace
Parameters: id, do
. id="save-subscription">
            <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.get_subscription_by_code
Binary
Namespace: NodeNamespace
Parameters: code, do
. code="[n.code_parameter
Macro
/]">
                <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.not
Binary
Namespace: BasicNamespace
Parameters: condition
.is_subscribed
Binary
Namespace: SubscriptionNamespace
>
                    <then>
                        <n.save
Binary
Namespace: SubscriptionNamespace
Parameters: to, type
 to="[n.subscription_to_field
Macro
Parameters: do
.value
Binary
Namespace: FieldNamespace
/]" type="INSTANT" />
                    </then>
                    <else.throw_template_exception
Binary
Namespace: BasicNamespace
Parameters: name
 name="already_subscribed"/>
                </n.if.not.is_subscribed>
            </n.page_node.get_subscription_by_code.>
        </n.catch_exception.>
        <n.html
Macro
Parameters: head, body
>
            <head>
                <meta name="robots" content="noindex,nofollow"/>
                <n.title
Macro
Parameters: text
.><t>Subscription Confirmation</t></n.title.>
            </head>
            <body>
                <n.edit_header
Macro
Parameters: first_text, second_text
 first_text="[n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.subject
Macro
Requires: node
/]" second_text="Subscription Confirmation" />
                <br/>
                <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.has_exception
Binary
Namespace: BasicNamespace
Parameters: for
 for="save-subscription">
                    <then>
                        <n.handle_exception
Binary
Namespace: NabbleNamespace
Parameters: for, do
. for="save-subscription">
                            <n.exception
Binary
Namespace: ExceptionNamespace
Parameters: name, do
. name="invalid_link">
                                <h2><t>Invalid Code</t></h2>
                                <p><t>The code in the URL is not valid.</t>
                                <t>Please contact Nabble Support if you need help.</t></p>
                            </n.exception.>
                            <n.exception
Binary
Namespace: ExceptionNamespace
Parameters: name, do
. name="already_subscribed">
                                <h2><t>Subscribed</t></h2>
                                <p><t>You are subscribed to <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.subject
Macro
Requires: node
/>.</t></p>
                            </n.exception.>
                        </n.handle_exception.>
                    </then>
                    <else>
                        <h2><t>Subscription Confirmed</t></h2>
                        <p><t>From now on, you will receive an email for each message posted under <t.location.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.subject
Macro
Requires: node
/>.</t></p>
                    </else>
                </n.if.has_exception>
            </body>
        </n.html>
    </n.node_page.>
</override_macro>
Overrides default macro
... in subscribe.naml
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<macro name="subscribe_by_code" requires="servlet">
    <n.node_page.>
        <n.catch_exception. id="save-subscription">
            <n.page_node.get_subscription_by_code. code="[n.code_parameter/]">
                <n.if.not.is_subscribed>
                    <then.save to="[n.subscription_to_field.value/]" type="INSTANT" />
                    <else.throw_template_exception name="already_subscribed"/>
                </n.if.not.is_subscribed>
            </n.page_node.get_subscription_by_code.>
        </n.catch_exception.>
        <n.html>
            <head>
                <meta name="robots" content="noindex,nofollow"/>
                <n.title.><t>Subscription Confirmation</t></n.title.>
            </head>
            <body>
                <n.edit_header first_text="[n.page_node.subject/]" second_text="Subscription Confirmation" />
                <br/>
                <n.if.has_exception for="save-subscription">
                    <then>
                        <n.handle_exception. for="save-subscription">
                            <n.exception. name="invalid_link">
                                <h2><t>Invalid Code</t></h2>
                                <p><t>The code in the URL is not valid.</t>
                                <t>Please contact Nabble Support if you need help.</t></p>
                            </n.exception.>
                            <n.exception. name="already_subscribed">
                                <h2><t>Already Subscribed</t></h2>
                                <p><t>You are already subscribed to <n.page_node.subject/>.</t></p>
                            </n.exception.>
                        </n.handle_exception.>
                    </then>
                    <else>
                        <h2><t>Subscription Confirmed</t></h2>
                        <p><t>From now on, you will receive an email for each message posted under <t.location.page_node.subject/>.</t></p>
                    </else>
                </n.if.has_exception>
            </body>
        </n.html>
    </n.node_page.>
</macro>