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.
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2009-05-07 02:37 am (UTC)(link)
It's possible to define new classes, but not possible to extend class definitions.

(though you can make a new class that extends an existing class).

But I'm afraid I don't see the connection with my comment, and I'm worried that I'm giving the wrong impression of what is/is not possible, somehow.
adalger: Earthrise as seen from the moon, captured on camera by the crew of Apollo 16 (Default)

[personal profile] adalger 2009-05-07 02:48 am (UTC)(link)
Okay. Is there any way to, say, extend the RecentPage class and then have that extended class be used in your layout in place of the pre-defined RecentPage class?
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2009-05-07 02:58 am (UTC)(link)
Hmm, yes. But that doesn't solve the original problem, because you don't have the data available, unless you are visiting an actual entry.
adalger: Earthrise as seen from the moon, captured on camera by the crew of Apollo 16 (Default)

[personal profile] adalger 2009-05-07 03:05 am (UTC)(link)
So, somewhere back in the coding, something only serves the data that fills the Comment[] array if the page passes the isa EntryPage test?
adalger: Earthrise as seen from the moon, captured on camera by the crew of Apollo 16 (Default)

[personal profile] adalger 2009-05-07 03:13 am (UTC)(link)
kk. Now I understand. Now all I need is a coolhunter to say "This would be cool to have changed." ;)