lektor-website/content/docs/api/db/pad/get/contents.lr

37 lines
1.1 KiB
Plaintext
Raw Normal View History

2015-12-19 14:52:17 +01:00
title: get
---
summary: Loads a single record.
---
type: method
---
signature: id, alt='_primary', page_num=None
---
body:
This can look up a single [Record :ref](../../record/) and return it. In templates this method
is particularly useful when having to work with other pages that are well
known to the system but some information should be pulled from. Note that
this loads by default the "primary" [Alternative :ref](../../../../content/alts/).
The path needs to be absolute with folder separated by slashes.
The default behavior is to load the unpaginated version of a record. If you
want to select a specific page for pagination, then you need to pass
`page_num` with a valid page number.
## Examples
This is a simple example that shows how to use the method in a template:
```html+jinja
{% set root = site.get('/') %}
<title>{{ this.title }} | {{ root.title }}</title>
```
Here another example that loads the current page but in another language:
```html+jinja
{% set other_lang = site.get(this._path, alt='ru') %}
<p>This page in Russian: {{ other_lang.title }}
```