Skip to content

Commit bcdefd4

Browse files
committed
Update link_to_prev/next examples
1 parent df15120 commit bcdefd4

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

tags/link_to_next.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,50 @@ Tag will accept the following attributes (**case-sensitive**) as well as the {%
5252
### Example 1: Link to next article using the article title
5353

5454
~~~ html
55-
<txp:link_to_next>
55+
<txp:link_to_next wraptag="div" class="nav_next">
5656
<txp:title />
5757
</txp:link_to_next>
5858
~~~
5959

60-
### Example 2: Link to next article using static text
60+
Important: The `<txp:link_to_next>` tag automatically has its container context set to *the next article*. Thus to retrieve the article title of this article, use the `<txp:title />` tag and *not* the `<txp:next_title />` tag. Using the latter tag in the `<txp:link_to_next>` container would 'skip' an article title. Compare this usage to Example 3 where the single tag is used and the `<txp:next_title />` is therefore appropriate to fetch information from the next document.
61+
{: .alert-block .information}
62+
63+
Other tags used: [next_title](/tags/next_title), [title](/tags/title).
64+
65+
### Example 2: Link to next article
6166

6267
~~~ html
6368
<txp:link_to_next showalways="1">
6469
Next
6570
</txp:link_to_next>
6671
~~~
6772

73+
or to display the text in the current site language:
74+
75+
~~~ html
76+
<txp:link_to_next showalways="1">
77+
<txp:text item="next" />
78+
</txp:link_to_next>
79+
~~~
80+
6881
This will always display the text 'Next', even when there is no next article.
6982

70-
Note: While `showalways` will enable this tag to display what is wrapped inside it, [next_title](/tags/next_title) returns nothing if there is no next title, so nothing is displayed. Use text, or the returned value, that you need displayed.
83+
Note: While `showalways` will enable this tag to display what is wrapped inside it, [next_title](/tags/next_title) returns nothing if there is no next title, so nothing is displayed. Use fixed text instead in this case.
7184
{: .alert-block .information}
7285

7386
### Example 3: Customising links
7487

75-
The container tag returns only a very basic link, which doesn't allow for customising the link title, or adding a CSS class, etc. Using the tag in its single tag capacity opens up a lot more possibilities.
88+
The container tag returns only a very basic link, which doesn't allow for customising the link title. Using the tag in its single tag capacity opens up more possibilities.
7689

77-
For example, to give the link an HTML `title` attribute of the next article's title, and also apply a `class` to it:
90+
To give the link an HTML `title` attribute of the next article's title:
7891

7992
~~~ html
8093
<a class="link--next" href="<txp:link_to_next />" title="<txp:next_title />">
8194
Next article →
8295
</a>
8396
~~~
8497

85-
Other tags used: [prev_title](/tags/next_title), [title](/tags/title).
98+
Other tags used: [next_title](/tags/next_title).
8699

87100
## Genealogy
88101

tags/link_to_prev.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ Tag will accept the following attributes (**case-sensitive**) as well as the {%
5252
### Example 1: Link to previous article using its title
5353

5454
~~~ html
55-
<txp:link_to_prev>
55+
<txp:link_to_prev wraptag="div" class="nav_next">
5656
<txp:title />
5757
</txp:link_to_prev>
5858
~~~
5959

60+
Important: The `<txp:link_to_prev>` tag automatically has its container context set to *the previous article*. Thus to retrieve the article title of this article, use the `<txp:title />` tag and *not* the `<txp:prev_title />` tag. Using the latter tag in the `<txp:link_to_prev>` container would 'skip' an article title. Compare this usage to Example 3 where the single tag is used and the `<txp:prev_title />` is therefore appropriate to fetch information from the previous document.
61+
{: .alert-block .information}
62+
63+
Other tags used: [prev_title](/tags/prev_title), [title](/tags/title).
64+
6065
### Example 2: Link to previous article using static text
6166

6267
~~~ html
@@ -65,24 +70,32 @@ Tag will accept the following attributes (**case-sensitive**) as well as the {%
6570
</txp:link_to_prev>
6671
~~~
6772

73+
or to display the text in the current site language:
74+
75+
~~~ html
76+
<txp:link_to_prev showalways="1">
77+
<txp:text item="prev" />
78+
</txp:link_to_prev>
79+
~~~
80+
6881
This will always display the text 'Previous', even when there is no previous article.
6982

70-
Note: While `showalways` will enable this tag to display what is wrapped inside it, [prev_title](/tags/prev_title) returns nothing if there is no previous title, so nothing is displayed. Use text, or the returned value, that you need displayed.
83+
Note: While `showalways` will enable this tag to display what is wrapped inside it, [prev_title](/tags/prev_title) returns nothing if there is no previous title, so nothing is displayed. Use fixed text instead in this case.
7184
{: .alert-block .information}
7285

7386
### Example 3: Customising links
7487

75-
The container tag returns only a very basic link, which doesn't allow for customising the link title, or adding a CSS class, etc. Using the tag in its single tag capacity opens up a lot more possibilities.
88+
The container tag returns only a very basic link, which doesn't allow for customising the link title. Using the tag in its single tag capacity opens up more possibilities.
7689

77-
For example, to give the link an HTML `title` attribute of the previous article's title, and also apply a `class` to it:
90+
To give the link an HTML `title` attribute of the previous article's title:
7891

7992
~~~ html
8093
<a class="link--prev" href="<txp:link_to_prev />" title="<txp:prev_title />">
8194
← Previous article
8295
</a>
8396
~~~
8497

85-
Other tags used: [prev_title](/tags/prev_title), [title](/tags/title).
98+
Other tags used: [prev_title](/tags/prev_title).
8699

87100
## Genealogy
88101

0 commit comments

Comments
 (0)