Merge pull request #63 from ajdavis/get-siblings
New get_siblings() method
This commit is contained in:
commit
481e85d4f4
|
@ -1,24 +0,0 @@
|
|||
title: get_next_sibling
|
||||
---
|
||||
summary: Returns the next record.
|
||||
---
|
||||
type: method
|
||||
---
|
||||
body:
|
||||
|
||||
Get the next record in this record's parent's list of children.
|
||||
|
||||
If the parent record has pagination enabled, then `get_prev_sibling` and
|
||||
`get_next_sibling` use the pagination query to filter and order the children.
|
||||
Otherwise, the parent's standard configuration for children is used.
|
||||
See [the pagination guide :ref](../../../../guides/pagination/) and the
|
||||
[page order guide :ref](../../../../guides/page-order/).
|
||||
|
||||
## Example
|
||||
|
||||
```html+jinja
|
||||
{% set newer = this.get_next_sibling() %}
|
||||
{% if newer %}
|
||||
<a href="{{ newer|url }}">Next article: {{ newer.title }}</a>
|
||||
{% endif %}
|
||||
```
|
|
@ -1,24 +0,0 @@
|
|||
title: get_prev_sibling
|
||||
---
|
||||
summary: Returns the previous record.
|
||||
---
|
||||
type: method
|
||||
---
|
||||
body:
|
||||
|
||||
Get the previous record in this record's parent's list of children.
|
||||
|
||||
If the parent record has pagination enabled, then `get_prev_sibling` and
|
||||
`get_next_sibling` use the pagination query to filter and order the children.
|
||||
Otherwise, the parent's standard configuration for children is used.
|
||||
See [the pagination guide :ref](../../../../guides/pagination/) and the
|
||||
[page order guide :ref](../../../../guides/page-order/).
|
||||
|
||||
## Example
|
||||
|
||||
```html+jinja
|
||||
{% set older = this.get_prev_sibling() %}
|
||||
{% if older %}
|
||||
<a href="{{ older|url }}">Previous article: {{ older.title }}</a>
|
||||
{% endif %}
|
||||
```
|
|
@ -0,0 +1,34 @@
|
|||
title: get_siblings
|
||||
---
|
||||
summary: The previous and next children of this page's parent.
|
||||
---
|
||||
type: method
|
||||
---
|
||||
body:
|
||||
|
||||
Get the previous and next record in this record's parent's list of children.
|
||||
|
||||
The returned object has attributes `prev_page` and `next_page`.
|
||||
Each can be a [Record :ref](../) or `None`.
|
||||
|
||||
If the parent record has pagination enabled, then use the pagination query to
|
||||
filter and order the children. Otherwise, the parent's standard configuration
|
||||
for children is used.
|
||||
See [the pagination guide :ref](../../../../guides/pagination/) and the
|
||||
[page order guide :ref](../../../../guides/page-order/).
|
||||
|
||||
## Example
|
||||
|
||||
```html+jinja
|
||||
{% set siblings = this.get_siblings() %}
|
||||
|
||||
{% if siblings.prev_page %}
|
||||
<a href="{{ siblings.prev_page|url }}">previous</a>
|
||||
{% endif %}
|
||||
|
||||
{% if siblings.next_page %}
|
||||
<a href="{{ siblings.next_page|url }}">next</a>
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
See also: [has_prev :ref](../has_prev/) and [has_next :ref](../has_next/).
|
|
@ -0,0 +1,27 @@
|
|||
title: has_next
|
||||
---
|
||||
summary: Whether the record has a next sibling.
|
||||
---
|
||||
type: method
|
||||
---
|
||||
body:
|
||||
|
||||
True if there is a next record in the parent's list of children.
|
||||
|
||||
If the parent record has pagination enabled, then use the pagination query to
|
||||
filter and order the children. Otherwise, the parent's standard configuration
|
||||
for children is used.
|
||||
See [the pagination guide :ref](../../../../guides/pagination/) and the
|
||||
[page order guide :ref](../../../../guides/page-order/).
|
||||
|
||||
## Example
|
||||
|
||||
```html+jinja
|
||||
{% if this.has_next() %}
|
||||
<a href="{{ this.get_siblings().next_page|url }}">next</a>
|
||||
{% else %}
|
||||
<p>This is the last entry.
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
See also: [has_prev :ref](../has_prev/) and [get_siblings :ref](../get_siblings/).
|
|
@ -0,0 +1,27 @@
|
|||
title: has_prev
|
||||
---
|
||||
summary: Whether the record has a previous sibling.
|
||||
---
|
||||
type: method
|
||||
---
|
||||
body:
|
||||
|
||||
True if there is a previous record in the parent's list of children.
|
||||
|
||||
If the parent record has pagination enabled, then use the pagination query to
|
||||
filter and order the children. Otherwise, the parent's standard configuration
|
||||
for children is used.
|
||||
See [the pagination guide :ref](../../../../guides/pagination/) and the
|
||||
[page order guide :ref](../../../../guides/page-order/).
|
||||
|
||||
## Example
|
||||
|
||||
```html+jinja
|
||||
{% if this.has_prev() %}
|
||||
<a href="{{ this.get_siblings().prev_page|url }}">previous</a>
|
||||
{% else %}
|
||||
<p>This is the first entry.
|
||||
{% endif %}
|
||||
```
|
||||
|
||||
See also: [has_next :ref](../has_next/) and [get_siblings :ref](../get_siblings/).
|
|
@ -19,8 +19,9 @@
|
|||
</div>
|
||||
{% endcall %}
|
||||
|
||||
{% set older = this.get_next_sibling() %}
|
||||
{% set newer = this.get_prev_sibling() %}
|
||||
{% set siblings = this.get_siblings() %}
|
||||
{% set older = siblings.next_page %}
|
||||
{% set newer = siblings.prev_page %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
|
|
Loading…
Reference in New Issue