component_help, posts by tag: class: recentpage - LiveJournal (original) (raw)
pyaari asked here how the RecentPage summary component could be altered to include a comment count next to each subject, so I decided to make this into a general post for everyone to see as this technique could be used to modify any of the other summary components as well.
Component uses the layout-defined function lay_print_summary()
to print the summary component. If you would like to modify the way any of them print, you need to override the function on it's respective page. For example, to change the way the summary prints on the Recent Page, you need to override RecentPage::lay_print_summary()
as shown in the code below. Because a FriendsPage is an extension of a RecentPage, overriding this function will affect both pages, so there are cases within the code to handle both page. Other page types are {DayPage, EntryPage, ReplyPage, MonthPage, YearPage}.
I wanted to show how to add more than just a comment count, so the code below formats the RecentPage entries in the form: <date> <time> : <security_icon> <subject> [+<comment_count]
and FriendsPage entries in the form: <poster_name> : <journal_name> : <security_icon> <subject> [+<comment_count>]
You can change the punctuation symbols by altering code in
red, and you can change the ordering by swapping the lines around. If you do this, be careful of where you place whitespace between elements on each line. Note also that the link on the subject takes you to the entry on the current page, and the link on the comment count takes you to the entry page (the one with comments) on that person/community's journal.