Malcolm
November 25, 2023, 11:51am
1
Continuing the discussion from Next parent slug :
I want to provide back links. They are complementary to next-slugs but work in the opposite direction, they would generate a link to the previous document.
Am I able to do this in a template? What would the code look like?
hbowie
November 26, 2023, 9:19pm
2
It’s not too hard to do in a template, just a little tricky.
Start by setting a global variable to hold the title of the previous page.
<?set prior-page = "" ?>
Follow this with your nextrec
command.
<?nextrec?>
Then, wherever you want the prior-page link to appear, you would want something like the following.
<?if "=$prior-page$=" ?>
<p>
Prior Page:
<a href="=$prior-page&f$=">
=$prior-page$=
</a>
</p>
<?endif?>
And then at some point before the loop
command:
<?set prior-page = "=$title$=" ?>
This assumes you’ve sorted the input into the desired sort sequence.
Hope this helps!
Let me know if questions or problems!
1 Like
Malcolm
November 27, 2023, 9:36am
3
Nice. That worked once I added the “.html” extension to the template code for the link.
<a href="=$prior-page&f$=.html">
1 Like