in response to
epigram's
s2flexisquares post.
in addition to using this code, you'll have to override print_entry() and include the following near the top of the function:
"""""";
class MyUtils {
function num_comments_in_thread(Comment[] comments) : int;
}
function MyUtils::num_comments_in_thread (Comment[] comments) : int {
var int total = 0;
foreach var Comment c ($comments) {
$total = $total + 1;
if (size $c.replies > 0) {
$total = $total + $this->num_comments_in_thread($c.replies);
}
}
return $total;
}
function YearPage::print_month(YearMonth m) {
if (not $m.has_entries) {
return;
}
var string month = $m->month_format();
"""
$month
$*text_view_month """;
foreach var int d (weekdays()) {
"""
"""+$*lang_dayname_short[$d]+"\n";
}
"""
""";
foreach var YearWeek w ($m.weeks) {
$w->print();
}
"""
""";
}
function MonthPage::print_body {
"""
""";
foreach var MonthDay d ($.days) {
if ($d.has_entries) {
var string day = lang_ordinal($d.day);
"""
$day
""";
$d->print_subjectlist();
"""
""";
}
}
"""
""";
}
function print_sidebar() {
# create helper vars for sidebar boxes
var string k1Sheader = "";
var string k1Sheader_one = """
""";
var string k1Sheader_two = "";
var string k1Scontent = "";
var string k1Scontent_one = """
""";
var string k1Scontent_two = "";
# create var for header of summary box
var string summary_header = "Page Summary";
# create helper vars for summary sidebar box
var Page p = get_page();
var Comment[] comments = [];
var Entry[] entries = [];
var int items = 0;
var string summary = "";
# if we're on a RecentPage or FriendsPage
if($p isa RecentPage) {
var RecentPage rp = $p as RecentPage;
# grab the entries and number of them
if(size($rp.entries) > 0) {
$entries = $rp.entries;
$items = size($entries);
}
}
# if we're on a YearPage
if($p isa YearPage) {
var YearPage yp = $p as YearPage;
var string month = "";
foreach var YearMonth m ($yp.months) {
if($m.has_entries) {
$month = """
""" + $m->month_format() + """""";
$month = "$k1Scontent_one$month$k1Scontent_two";
$summary = $summary + $month + "\n";
}
}
}
# if we're on a MonthPage
if($p isa MonthPage) {
var MonthPage mp = $p as MonthPage;
var string day = "";
foreach var MonthDay d ($mp.days) {
if($d.num_entries > 0) {
$day = """
""" + $d.date->date_format("long") + """""";
$day = "$k1Scontent_one$day$k1Scontent_two";
$summary = $summary + $day + "\n";
}
}
}
# if we're on a DayPage
if($p isa DayPage) {
var DayPage dp = $p as DayPage;
if(size($dp.entries) > 0) {
$entries = $dp.entries;
$items = size($entries);
}
}
# if we're on an EntryPage
if($p isa EntryPage) {
var EntryPage ep = $p as EntryPage;
if(size($ep.comments) > 0) {
# grab the comments and number of them
$comments = $ep.comments;
$items = size($comments);
}
}
# if we got entries from Recent/Friends/DayPage
if(size($entries) > 0) {
var string security = "";
var string subject = "";
var string poster = "";
var string journal = "";
var string count = "";
var string item = "";
# cycle thru entries
foreach var Entry e ($entries) {
$security = "";
$subject = "";
$poster = "";
$journal = "";
$count = "";
$item = "";
# get security icon
if($e.security_icon.url != "") {
$security = $e.security_icon + " ";
}
# get subject
if($e.subject != "") {
$subject = striphtml($e.subject);
} else {
$subject = """$*text_nosubject""";
}
# get journal
if($p.view == "friends" and (not ($e.poster->equals($e.journal)))) {
$journal = "$e.journal ::
";
}
# get poster
if($p.view == "friends" or (not ($e.poster->equals($e.journal)))) {
$poster = "$e.poster :
";
}
# get comment count
$count = """ [
+$e.comments.count]""";
# put it all together
$item = """$security$journal$poster
$subject$count""";
# format it for a sidebar box line item
$item = "$k1Scontent_one$item$k1Scontent_two";
# add it to the summary var
$summary = $summary + $item + "\n";
}
}
# if we got comments from EntryPage
if(size($comments) > 0) {
var MyUtils mu = new MyUtils;
var string subject = "";
var string icon = "";
var string poster = "";
var string count = "";
var string item = "";
# cycle thru comments
foreach var Comment c ($comments) {
$subject = "";
$icon = "";
$poster = "";
$count = "";
$item = "";
# get subject icon
$icon = $c.subject_icon.url != "" ? $c.subject_icon + " " : "";
# get subject
$subject = $c.subject != "" ? $c.subject : """$*text_nosubject""";
$subject = "$subject";
# get poster
$poster = $c.poster.username != "" ? $c.poster + "" : """$*text_poster_anonymous""";
$poster = $poster + " :
";
# get reply count
$count = """ [
+""" + $mu->num_comments_in_thread($c.replies) + """]""";
# put it all together
$item = """$icon$poster
$subject$count""";
# format it for a sidebar box line item
$item = "$k1Scontent_one$item$k1Scontent_two";
# add it to the summary var
$summary = $summary + $item + "\n";
}
}
# if we've got a summary
if($summary != "") {
# set header
$k1Sheader = $summary_header;
# set content
$k1Scontent = $summary;
# print sidebar box
print_sidebar_box("$k1Sheader_one$k1Sheader$k1Sheader_two", "$k1Scontent_one$k1Scontent$k1Scontent_two");
}
sidebar_order($*sidebar_order_1);
sidebar_order($*sidebar_order_2);
sidebar_order($*sidebar_order_3);
sidebar_order($*sidebar_order_4);
}