diff --git a/content/docs/api/db/record/getitem/contents.lr b/content/docs/api/db/record/getitem/contents.lr new file mode 100644 index 00000000..99baf1d2 --- /dev/null +++ b/content/docs/api/db/record/getitem/contents.lr @@ -0,0 +1,22 @@ +title: [] +--- +summary: Looks up a field from the type. +--- +type: operator +--- +body: + +The “get-item” operator is used to look up a field from a record. Within +templates attribute access automatically falls back to this operator which +is why you can typically access `foo.bar` instead of `foo['bar']` unless a +conflict with a record property exists. + +All available fields can be accessed this way (model defined fields as well +as system fields which are prefixed by an underscore). + +## Example + +```python +for child in this.children: + print 'ID: %s' % child['_id'] +``` diff --git a/content/docs/api/db/system-fields/alt/contents.lr b/content/docs/api/db/system-fields/alt/contents.lr new file mode 100644 index 00000000..fba8eb90 --- /dev/null +++ b/content/docs/api/db/system-fields/alt/contents.lr @@ -0,0 +1,11 @@ +title: _alt +--- +summary: The alt for this record. +--- +type: sysfield +--- +body: + +This field points to the [Alternative :ref](../../../../content/alts/) of +the page. This should be considered as an internal field that is exposed +through the [alt :ref](../../obj/alt/) source object property instead. diff --git a/content/docs/api/db/system-fields/attachment-type/contents.lr b/content/docs/api/db/system-fields/attachment-type/contents.lr new file mode 100644 index 00000000..5471f6e7 --- /dev/null +++ b/content/docs/api/db/system-fields/attachment-type/contents.lr @@ -0,0 +1,14 @@ +title: _attachment_type +--- +summary: An indication of the attachment type. +--- +type: sysfield +--- +body: + +This indicates the type of the attachment. Currently only a small set of +attachments is detected. The most useful attachment type is `image` which +identifies images. The attachments are detected by the file extension. + +!!!! This feature in many ways does not entirely work as you would expect +and should be taken is something that will improve in future versions. diff --git a/content/docs/api/db/system-fields/contents.lr b/content/docs/api/db/system-fields/contents.lr new file mode 100644 index 00000000..9d48a849 --- /dev/null +++ b/content/docs/api/db/system-fields/contents.lr @@ -0,0 +1,13 @@ +title: System Fields +--- +summary: The complete list of system fields in Lektor +--- +body: + +All records have a few system fields available in addition to the fields +defined by the data model. These fields are always there and control internal +behavior in Lektor. They are prefixed by an underscore to separate them +from the fields a model defines. + +Many system fields are hidden from the admin panel but some can be changed +there (`_template`, `_hidden`, and a few others). diff --git a/content/docs/api/db/system-fields/discoverable/contents.lr b/content/docs/api/db/system-fields/discoverable/contents.lr new file mode 100644 index 00000000..080035d8 --- /dev/null +++ b/content/docs/api/db/system-fields/discoverable/contents.lr @@ -0,0 +1,20 @@ +title: _discoverable +--- +summary: Controls if this page is picked up by collection queries by default. +--- +type: sysfield +--- +version_added: 2.0 +--- +body: + +By default any non hidden page is returned from `.children` on iteration. This +field can be set to `no` to hide a page from such default queries. This +implicitly hides a page for most template operations but Lektor will still +build it. This for instance is very useful for draft blog posts. If a post is +set to not being discoverable it will be hidden from the blog index without +further custom template code, but someone who knows the URL can still find it. + +This is also particularly useful to hide special pages such as `sitemap.xml` +which would otherwise cause problems because generic code might not expect +it. diff --git a/content/docs/api/db/system-fields/gid/contents.lr b/content/docs/api/db/system-fields/gid/contents.lr new file mode 100644 index 00000000..11353d03 --- /dev/null +++ b/content/docs/api/db/system-fields/gid/contents.lr @@ -0,0 +1,20 @@ +title: _gid +--- +summary: A globally unique ID of the page. +--- +type: sysfield +--- +body: + +The `_gid` is the MD5 hashed version of the page's [`_path`](../path/). This +is useful in situations where a stable ID is needed that follows a certain +format. For instance it can come in useful when a ID is needed for a DOM +element. + +## Example + +```html+jinja +
+... + +``` diff --git a/content/docs/api/db/system-fields/hidden/contents.lr b/content/docs/api/db/system-fields/hidden/contents.lr new file mode 100644 index 00000000..330e6bc8 --- /dev/null +++ b/content/docs/api/db/system-fields/hidden/contents.lr @@ -0,0 +1,20 @@ +title: _hidden +--- +summary: Controls if the page should be built or not. +--- +type: sysfield +--- +body: + +This field controls if Lektor should process the page into a build artifact. +By default each page is built into a build artifact (HTML page) and each +attachment is processed. This can be prevented by setting `_hidden` to `yes`. + +This also automatically applies to all children of a page unless they +forcefully override this setting. + +This is useful for more advanced setups like [Single Page Applications +:ref](../../../../guides/single-page/). + +Hidden pages are automatically also removed from the `.children` property +of records but stay available for querying via the pad. diff --git a/content/docs/api/db/system-fields/id/contents.lr b/content/docs/api/db/system-fields/id/contents.lr new file mode 100644 index 00000000..a26d4311 --- /dev/null +++ b/content/docs/api/db/system-fields/id/contents.lr @@ -0,0 +1,32 @@ +title: _id +--- +summary: The local identifier of a record. +--- +type: sysfield +--- +body: + +Each record has an `_id`. This ID is basically a form of the filename. +Depending on if you are looking at an attachment or a page the rules are +slightly different. + +For pages the ID is the name of the folder. So if you have a page called +`docs/overview/contents.lr` then `_id` is `overview`. If you have however +an attachment named `docs/overview/screenshot.jpg` the `_id` will be the +filename of the attachment: `screenshot.jpg`. + +Note that IDs are not globally unique! There is also the `_path` which is +the entire path if the record. + +The `_id` is automatically set and cannot be overridden. + +## Example + +```html+jinja + +``` diff --git a/content/docs/api/db/system-fields/model/contents.lr b/content/docs/api/db/system-fields/model/contents.lr new file mode 100644 index 00000000..d8f2f3b8 --- /dev/null +++ b/content/docs/api/db/system-fields/model/contents.lr @@ -0,0 +1,23 @@ +title: _model +--- +summary: The model the record uses for its fields. +--- +type: sysfield +--- +body: + +This field selects the model that should be used for non-system fields. In +many situations the model is picked automatically but for equally many +situations it needs to be selected manually. + +This field is most useful for filtering when operating on mixed collections. + +## Example + +```html+jinja +