change_title_and_meta_tags

NAML documentation   Watch a video
   Usages of this macro
... in change_title_and_meta_tags.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<macro name="change_title_and_meta_tags" requires="servlet">
    <n.node_page
Macro
Requires: servlet
Parameters: do
.>
        <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.not
Binary
Namespace: BasicNamespace
Parameters: condition
.visitor
Binary
Namespace: ServletNamespace
Parameters: do
.is_site_admin
Macro
Requires: user
>
            <then>
                <n.login
Macro
Requires: servlet
Parameters: message
.><t>Only authorized users can proceed in this area.</t></n.login.>
            </then>
        </n.if.not.visitor.is_site_admin>
 
        <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.is_submitted_form
Macro
Requires: servlet
>
            <then>
                <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.has_custom_values_field
Macro
Parameters: do
.is_checked
Macro
Requires: field
>
                    <then>
                        <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.set_property
Binary
Namespace: NodeNamespace
Parameters: name, value
 name="page_title" value="[n.page_title_field
Macro
Parameters: do
.value
Binary
Namespace: FieldNamespace
/]"/>
                        <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.set_property
Binary
Namespace: NodeNamespace
Parameters: name, value
 name="page_meta_description" value="[n.page_meta_description_field
Macro
Parameters: do
.value
Binary
Namespace: FieldNamespace
/]"/>
                    </then>
                    <else>
                        <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.delete_property
Binary
Namespace: NodeNamespace
Parameters: name
 name="page_title"/>
                        <n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.delete_property
Binary
Namespace: NodeNamespace
Parameters: name
 name="page_meta_description"/>
                    </else>
                </n.if.has_custom_values_field.is_checked>
                <n.redirect_to
Binary
Namespace: ServletNamespace
Parameters: url
.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.path
Macro
Requires: node
Parameters: template, date, index_record
/>
            </then>
            <else>
                <n.has_custom_values_field
Macro
Parameters: do
.set_value
Binary
Namespace: FieldNamespace
Parameters: value
 value="[n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.has_custom_meta_tags
Macro
Requires: node
/]"/>
                <n.page_title_field
Macro
Parameters: do
.set_value
Binary
Namespace: FieldNamespace
Parameters: value
.property_default
Macro
Parameters: default, property
 property="page_title" default="[n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.default_title_contents
Macro
Requires: node
/]"/>
                <n.page_meta_description_field
Macro
Parameters: do
.set_value
Binary
Namespace: FieldNamespace
Parameters: value
.property_default
Macro
Parameters: default, property
 property="page_meta_description" default="[n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.default_meta_description
Binary
Namespace: NodeNamespace
/]"/>
            </else>
        </n.if.is_submitted_form>
        <n.html
Macro
Parameters: head, body
>
            <head>
                <meta name="robots" content="noindex,nofollow"/>
                <n.title
Macro
Parameters: text
.><t>Change title and meta tags</t></n.title.>
                <style type="text/css">
                    textarea {
                        margin:.4em 0 2em;
                        width:40em;
                        height:3em;
                    }
                </style>
                <script type="text/javascript">
                    var txt_counter = '<t>Current length: <t.number>#1</t.number> characters</t>';
                    function updateCounters(){
                        $('textarea').each(function() {
                            var $textarea = $(this);
                            $textarea.prev().html(txt_counter.replace(/#1/, $textarea.val().length));
                        });
                    };
 
                    function enableFields() {
                        var checked = $('#has_custom_values').is(':checked');
                        var $fields = $('#page_title,#page_meta_description');
                        if (checked) {
                            $('textarea').keyup(updateCounters);
                            $fields.removeAttr('disabled');
                            $fields.eq(0).focus();
                        } else
                            $fields.attr('disabled', true);
                    };
                    $(document).ready(function() {
                        enableFields();
                        updateCounters();
                        $('#has_custom_values').click(enableFields);
                    });
                </script>
            </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="[t]Change title and meta tags[/t]" />
                <div class="weak-color" style="margin:1em 0">
                    <t>Here you can customize the title and meta tags of the <t.location><i><n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.subject
Macro
Requires: node
/></i></t.location> page.</t>
                    <t>The meta information below can help you optimize this page for search engines (e.g., google, yahoo!, etc.).</t>
                </div>
                <n.form
Macro
Requires: servlet
Parameters: macro, method, onsubmit, content
.>
                    <div style="margin:1em 0 0;">
                        <n.has_custom_values_field
Macro
Parameters: do
.checkbox
Macro
Requires: field
Parameters: style
 />
                        <label for="[n.has_custom_values_field
Macro
Parameters: do
.name
Binary
Namespace: FieldNamespace
/]" class="big-title second-font"><t>Use custom values</t></label><br/>
                    </div>
 
                    <div style="margin:1em 0 0 3em">
                        <div class="big-title second-font"><t>Page Title</t></div>
                        <div class="weak-color"><t>Enter a context-rich title that clearly identifies this page.</t></div>
                        <div class="weak-color"><t>The title should ideally be less than 70 characters in length.</t></div>
                        <div class="weak-color"></div>
                        <n.page_title_field
Macro
Parameters: do
.textarea
Macro
Requires: field
Parameters: maxlength, tabindex, style, wrap
 maxlength="100"/>
 
                        <div class="big-title second-font"><t>Meta Description</t></div>
                        <div class="weak-color"><t>Enter a brief and concise summary of your page's content.</t></div>
                        <div class="weak-color"><t>Limit your description to 155 characters or 170 characters at most.</t></div>
                        <div class="weak-color"></div>
                        <n.page_meta_description_field
Macro
Parameters: do
.textarea
Macro
Requires: field
Parameters: maxlength, tabindex, style, wrap
 maxlength="250"/>
                    </div>
 
                    <div>
                        <input type="submit" class="toolbar action-button" value="[t]Save Changes[/t]" />
                        <t>or</t> <a href="[n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.path
Macro
Requires: node
Parameters: template, date, index_record
/]"><t>Cancel</t></a>
                    </div>
                </n.form.>
            </body>
        </n.html>
    </n.node_page.>
</macro>