lastdance: (Default)
lastdance ([personal profile] lastdance) wrote in [community profile] style_system2009-05-05 09:26 pm

Calling functions in other classes

I've been reading S2 documentation like crazy, and I'm pretty sure the answer is 'no' but I'm going to throw out the question anyway:

Is there any possible way to call functions from a different view than the one you're currently on? For example, the EntryPage class has a function print_comments. But what if I want to print the subjects of the 5 latest comments on the Recent view (maybe in the sidebar)? The RecentPage class doesn't include that function, so I'm assuming there's no way to call it unless the core was rewritten to add it into RecentPage and allow it to take parameters so it knows which comments to pull back. Am I correct in that assumption?

I'll gladly take the question elsewhere if this isn't the right place. Any direction would be so much appreciated.
adalger: Earthrise as seen from the moon, captured on camera by the crew of Apollo 16 (Default)

[personal profile] adalger 2009-05-06 07:01 am (UTC)(link)
This is the right place to ask. :)

You're pretty much correct here. You'd have to do some fancy coding in the RecentPage class to have it retrieve comment subjects for each entry on the page. The EntryPage class is only concerned with a single entry, so it's pretty clear what comments it's looking for, but the RecentPage class isn't built to display any comments, so it's not designed to even care about them beyond how many there are.

It's an interesting idea. Do you mean the 5 most recent comments per entry, or the 5 most recent comments on any entry on the page? The latter would be a little trickier, because you'd have to find probably the five most recent comments on each entry, then sort for which of all those are the five absolute most recent.