m_rsc
Page model.
This model provides an interface to all page information. It also provides an easy way to fetch edges from pages without using the m_edge model.
Properties
All stored texts are HTML escaped, except for the body text which is stored as-is and assumed to be valid XHTML. Retrieved texts are always binaries. Dates are stored as a standard Erlang date time tuple, for example {{2008,12,10},{15,30,00}}. Retrieved dates are in the local time of the server.
A page has the following properties accessible from the templates:
| Property | Description | Example value |
| id | Id of the page, an integer. | 42 |
| title | Title of the page. Returns a binary. | <<"Breaking News">> |
| short_title | Short title of the page. Used in menus. Returns a binary. | <<"News!">> |
| summary | Summary of the page. Returns a binary or undefined. | <<"Page summary.">> |
| body | The HTML body of a page. Returns a binary or undefined. | <<"<p>Hello</p>">> |
| date_start | Start date when the page has a period. Examples are events or the birth date of a person. Returns a datetime tuple or undefined. | {{2008,12,10},{15,30,00}} |
| date_end | End date when the page has a period. Returns a datetime tuple or undefined. When there is a start date then there is also an end date. | {{2009,12,5},{23,59,59}} |
| name | Unique name of the page. Returns a binary of undefined. Valid characters are a-z, 0-9 and _ | <<"page_home">> |
| page_path | Unique path of the page, used for url generation. Returns a binary or undefined. Valid characters are a-z, 0-9, / and - | <<"/">> |
| page_url | The url of the page. Derived using the page’s category, the page id and its slug. Returns a non flattened list. Returns the binary page_path when it is set. | [$/, "blog", [$/, "42"]] |
| default_page_url | The page without considering its page_path setting. | [$/, "page", [$/, "42", [$/, "my-slug"]] |
| is_authoritative | Whether this page originated on this site or is imported and maintained on another site. Return a boolean. | true |
| uri | The absolute unique uri of this resource. Refers to the “id” dispatch rule for authoritative (local) resources. Returns a binary. | <<"http://example.com/id/42">> |
| category_id | Id of the category the page belongs to. Returns an integer. | 102 |
| category | Category record the page belongs to. Returns a property list. | [{id,102},{parent_id,undefined], ... ,{name, <<"person">>}] |
| seo_noindex | Whether to let search engines index this page. Returns a boolean or undefined. | false |
| seo_title | Title for on top of the browser window. Returns a binary or undefined. | <<"Welcome Title">> |
| slug | Slug used for url generation, appended to page urls. Binary or undefined. Valid characters are a-z, 0-9 and - | <<"the-world-is-flat">> |
| seo_keywords | Keywords for search engine optimization. List of keywords separated with commas. Returns a binary or undefined. | <<"world, model, flat">> |
| seo_desc | Page description for search engines. Returns a binary or undefined. | <<"The truth about the world's shape">> |
| is_me | Check if this page is the current user’s person page. Returns a boolean. | false |
| is_visible | Check if this page is visible for the current user. Returns a boolean. | true |
| is_editable | Check if this page is editable by the current user. Returns a boolean. | false |
| is_ingroup | Check if the current user is a member of the group the page belongs to. Returns a boolean. | true |
| exists | Check if the page exists. Useful when checking if a named page is present or not. Returns a boolean. | true |
| is_a | Returns a list of the category hierarchy the page belongs to. The list is suitable for indexing with category atoms. Example usage: | [{text,true}, {article,true}] |
| is_cat | Direct check if a page is a certain category. More efficient then is_a. Example usage: | true |
| is_featured | If featured checked or not. Returns a boolean | false |
| is_protected | If this page is protected from deletion. Returns a boolean | false |
| is_published | If this page has been published. Returns a boolean | true |
| publication_start | Start date of the publication period. Returns a datetime tuple. | {{2009,12,24},{9,0,0}} |
| publication_end | End date of the publication period. Returns a datetime tuple. | {{9999,8,17},{12,0,0}} |
| visible_for | Visibility level. Returns an integer. 0 = world visible, 1 = only for logged on users, 2 = only for group members. | 0 |
| group_id | Id of the group the page is in, used for access control. Returns an integer. | 204 |
| group | Group record the page is in. Returns a property list with group settings. | [{id,204}, {is_admin,true}, {is_supervisor,true}, {is_community_publisher,true}, {is_public_publisher, true}] |
| o | Used to access the objects of page: the pages this page refers to. Returns a function which should be indexed with the edge’s predicate name (atom). When indexed the function will return a list of integers. Example usage: This returns the first author that is linked from this page. | fun(Predicate,Context) |
| s | Access the subjects of a page: the pages that are referring to this page. Returns a function which should be indexed with the edge’s predicate name (atom). When indexed the function will return a list of integers. Example usage: This returns the first article that links to me with a author connection. | fun(Predicate,Context) |
| op | Returns a list of all predicates on edges from this page. The predicates are atoms. | [about, related] |
| sp | Returns a list of all predicates on edges to this page. The predicates are atoms. | [author] |
| predicates_edit | Returns a list of all allowed predicates from this page. Used for editing the page. Returns a list of predicate ids (in contrast with the atoms of op and sp). | [308,300,304,303,302,300] |
| media | Return a list of all media ids connected to the page. The media are connected with the predicate “depiction”. | [842,3078] |
| medium | Return a property list describing the file or medium attached to the page. A medium record is present for pages that are an image, video etc. Returns undefined when there is no medium defined. See the model m_media for more information. | [ {id,512}, {filename, <<"2009/1…">>, … ] |
| depiction | Return the medium record that can be used for the image of a page. Either returns a medium page attached to the page or the medium record of the page itself. When no medium is found then undefined is returned. | [ {id,512}, {filename, <<"2009/1…">>, … ] |
| E-mail address. Returns a binary or undefined. | <<"me@example.com">> | |
| website | URL of a website. Returns a binary or undefined. | <<"http://zotonic.com">> |
| phone | Phone number. Returns a binary or undefined. | <<"+31201234567">> |
| phone_alt | Alternative phone number. Returns a binary or undefined. | undefined |
| phone_emergency | Phone number to call in emergencies. | <<"112">> |
| address_street_1 | Address line 1. Returns a binary or undefined. | |
| address_street_2 | Address line 2. Returns a binary or undefined. | |
| address_city | City part of address. Returns a binary or undefined. | |
| address_postcode | Postcode part of address. Returns a binary or undefined. | |
| address_state | State part of address. Returns a binary or undefined. | |
| address_country | Country part of address. Returns a binary or undefined. | |
| mail_street_1 | Mailing address line 1. Returns a binary or undefined. | |
| mail_street_2 | Mailing address line 2. Returns a binary or undefined. | |
| mail_city | City part of mailing address. Returns a binary or undefined. | |
| mail_postcode | Postcode part of mailing address. Returns a binary or undefined. | |
| mail_state | State part of mailing address. Returns a binary or undefined. | |
| mail_country | Country part of mailing address. Returns a binary or undefined. | |
| name_first | First name of person. Returns a binary or undefined. | |
| name_middle | Middle name of person. Returns a binary of undefined. | |
| name_surname_prefix | Prefix for the surname of a person. Returns a binary or undefined. | <<"van der"">, <<"von">> |
| name_surname | Surname or family name of person. Returns a binary or undefined. |
This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.
Comments
Zak
Posted 1 year, 8 months ago.
404 upon clicking link for edge model in first paragraph:
Resource not found: "/model-m-edge"
(link for edge is valid in the list of models however)
Arjan Scherpenisse
Posted 1 month, 7 days ago.
Fixed ;)