Go to page content

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:

PropertyDescriptionExample value
idId of the page, an integer.42
titleTitle of the page. Returns a binary.<<"Breaking News">>
short_titleShort title of the page. Used in menus. Returns a binary.<<"News!">>
summarySummary of the page. Returns a binary or undefined.<<"Page summary.">>
bodyThe HTML body of a page. Returns a binary or undefined.<<"<p>Hello</p>">>
date_startStart 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_endEnd 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}}
nameUnique name of the page. Returns a binary of undefined. Valid characters are a-z, 0-9 and _<<"page_home">>
page_pathUnique path of the page, used for url generation. Returns a binary or undefined. Valid characters are a-z, 0-9, / and -<<"/">>
page_urlThe 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_urlThe page without considering its page_path setting.[$/, "page", [$/, "42", [$/, "my-slug"]]
is_authoritativeWhether this page originated on this site or is imported and maintained on another site. Return a boolean.true
uriThe 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_idId of the category the page belongs to. Returns an integer.102
categoryCategory record the page belongs to. Returns a property list.[{id,102},{parent_id,undefined], ... ,{name, <<"person">>}]
seo_noindexWhether to let search engines index this page. Returns a boolean or undefined.false
seo_titleTitle for on top of the browser window. Returns a binary or undefined.<<"Welcome Title">>
slugSlug used for url generation, appended to page urls. Binary or undefined. Valid characters are a-z, 0-9 and -<<"the-world-is-flat">>
seo_keywordsKeywords for search engine optimization. List of keywords separated with commas. Returns a binary or undefined.<<"world, model, flat">>
seo_descPage description for search engines. Returns a binary or undefined.<<"The truth about the world's shape">>
is_meCheck if this page is the current user’s person page. Returns a boolean.false
is_visibleCheck if this page is visible for the current user. Returns a boolean.true
is_editableCheck if this page is editable by the current user. Returns a boolean.false
is_ingroupCheck if the current user is a member of the group the page belongs to. Returns a boolean.true
existsCheck 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:
{{ m.rsc[id].is_a.article }}

[{text,true}, {article,true}]
is_cat

Direct check if a page is a certain category. More efficient then is_a.

Example usage:
{{ m.rsc[id].is_cat.person }}

true
is_featuredIf featured checked or not. Returns a booleanfalse
is_protectedIf this page is protected from deletion. Returns a boolean

false

is_publishedIf this page has been published. Returns a booleantrue
publication_startStart date of the publication period. Returns a datetime tuple.{{2009,12,24},{9,0,0}}
publication_endEnd date of the publication period. Returns a datetime tuple.{{9999,8,17},{12,0,0}}
visible_forVisibility level. Returns an integer. 0 = world visible, 1 = only for logged on users, 2 = only for group members.0
group_idId of the group the page is in, used for access control. Returns an integer.204
groupGroup 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:
{{ m.rsc[id].o.author[1].title }}

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:
{{ m.rsc[id].s.author[1].title }}

This returns the first article that links to me with a author connection.

fun(Predicate,Context)
opReturns a list of all predicates on edges from this page. The predicates are atoms.[about, related]
spReturns a list of all predicates on edges to this page. The predicates are atoms.[author]
predicates_editReturns 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]

mediaReturn a list of all media ids connected to the page. The media are connected with the predicate “depiction”.[842,3078]
mediumReturn 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…">>, … ]
depictionReturn 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…">>, … ]
emailE-mail address. Returns a binary or undefined.<<"me@example.com">>
websiteURL of a website. Returns a binary or undefined.<<"http://zotonic.com">>
phonePhone number. Returns a binary or undefined.<<"+31201234567">>
phone_altAlternative phone number. Returns a binary or undefined.undefined
phone_emergencyPhone number to call in emergencies.<<"112">>
address_street_1Address line 1. Returns a binary or undefined. 
address_street_2Address line 2. Returns a binary or undefined. 
address_cityCity part of address. Returns a binary or undefined. 
address_postcodePostcode part of address. Returns a binary or undefined. 
address_stateState part of address. Returns a binary or undefined. 
address_countryCountry part of address. Returns a binary or undefined. 
mail_street_1Mailing address line 1. Returns a binary or undefined. 
mail_street_2Mailing address line 2. Returns a binary or undefined. 
mail_cityCity part of mailing address. Returns a binary or undefined. 
mail_postcodePostcode part of mailing address. Returns a binary or undefined. 
mail_stateState part of mailing address. Returns a binary or undefined. 
mail_countryCountry part of mailing address. Returns a binary or undefined. 
name_firstFirst name of person. Returns a binary or undefined. 
name_middleMiddle name of person. Returns a binary of undefined. 
name_surname_prefixPrefix for the surname of a person. Returns a binary or undefined.<<"van der"">, <<"von">>
name_surnameSurname 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

  • avatar

    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)

  • avatar

    Arjan Scherpenisse

    Posted 1 month, 7 days ago.

    Fixed ;)