The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][A Novel Conundrum] Reversing the order of the entries
howto_user wrote in s2howto
Paid Accounts Only
The following tutorial requires creating and editing a custom style, which in turn requires a paid, permanent, or early adopter account. Please read What are the paid account benefits? and How do I buy a paid account? to learn about the paid account benefits and how to buy a paid account.

This tutorial describes a simple method for reversing the order of entries on your Recent Entries page, changing them from reverse-chronological to chronological, and reversing the entries on your Friends page, changing them to the order in which they were posted to LiveJournal servers, in the layout A Novel Conundrum. This will only reverse the order of entries on each page — navigation will still work in reverse-chronological order.

This tutorial will replace the function RecentPage::print_body and or FriendsPage::print_body. This new code will be placed in a theme layer. If you already have a theme layer for this style, you can simply edit it. Otherwise, you need to create one as explained in the Theme Layer tutorial.

You will need to copy the following code into your theme layer, making sure to include everything:

function RecentPage::print_body() {
    foreach var Entry e (reverse $.entries) {
        $this->print_entry($e);
    }
"""

<div align="center" class="bs" style="line-height: ${*font_leading}pt;"><img
src="$*dingbar_url" style="text-align:center;" alt="$*text_dingbar_alt" /></div>
<div align="center"><h2>
""";

    # go forward/backward if possible
    if ($.nav.forward_url != "" or $.nav.backward_url != "") {
        var string sep;
        var string back;
        var string forward;
        if ($.nav.backward_url != "") {
            $back = """<a href="$.nav.backward_url">Previous</a>""";
        }
        if ($.nav.forward_url != "") {
            $forward = """<a href="$.nav.forward_url">Next</a>""";
        }
        if ($back != "" and $forward != "") { $sep = " &middot; "; }
        "$back$sep$forward";
    }
    "</h2></div>";
}

The word "reverse" in orange changes the order of the entries.

Note that the above code will reverse the order of the entries on both your Recent Entries page and your Friends page. If you want to reverse the order of entries on your Friends page only, you will need to change the word RecentPage (in green) to FriendsPage in the preceding block of code. Conversely, if you don't want the above code to affect your Friends page in this way, you will also need to add the following block of code, again making sure to include everything:

function FriendsPage::print_body() {
    foreach var Entry e ($.entries) {
        $this->print_entry($e);
    }
"""
<div align="center" class="bs" style="line-height: ${*font_leading}pt;"><img
src="$*dingbar_url" style="text-align:center;" alt="$*text_dingbar_alt" /></div>
<div align="center"><h2>

""";

    # go forward/backward if possible
    if ($.nav.forward_url != "" or $.nav.backward_url != "") {
        var string sep;
        var string back;
        var string forward;
        if ($.nav.backward_url != "") {
            $back = """<a href="$.nav.backward_url">Previous</a>""";
        }
        if ($.nav.forward_url != "") {
            $forward = """<a href="$.nav.forward_url">Next</a>""";
        }
        if ($back != "" and $forward != "") { $sep = " &middot; "; }
        "$back$sep$forward";
    }
    "</h2></div>";
}

Note the absence of the word "reverse" and that this time the method "print_body" is called from "FriendsPage" rather than "RecentPage".

Compile your layer, and it's ready to use. You will need to apply your theme layer via the Customize interface in order for your changes to take effect.

Originally written by skywhisperer for Tabular Indent, with elements borrowed from a previous tutorial by gamble. Re-written by camomiletea. Shamelessly cribbed, simplified and reworded in spots by pauamma for A Novel Conundrum.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account