av8rmike: Neo from Matrix, text: I know S2 (I know s2)
(Probably only of interest to [livejournal.com profile] camomiletea, [livejournal.com profile] scaryjeff, [livejournal.com profile] afuna, or anyone else in Styles support)

There was a recent request about substituting a user's default userpic for the one they'd selected for a particular post. We figured it was possible through S2, but we don't give that level of detail through Support. I found out something interesting while trying to figure it out for myself...

The S2 Core stores the entry user icon in $userpic, an Image member of the EntryLite class (usually called in print_entry() like $e.userpic.url). A user's default icon is stored in the User class, which is derived from UserLite. EntryLite class also contains a UserLite object called $poster, the author of the entry. Since Expressive (unlike other layouts) passes the EntryLite object into print_entry() directly, I thought I could get away with something like this:

var User u = $e.poster as User;
var Image def_pic = $u.default_pic;
var string userpic = ($showuserpic and defined $e.userpic) ? ($def_pic + "<br />") : "";
It compiles, but it doesn't work, it just comes up with an empty string. Even trying to isolate the Image members doesn't work:

var string pic_url = """<img src="$def_pic.url" alt="$e.userpic.alttext" title="$e.poster.name" height="$def_pic.height" width="$def_pic.width" />""";

Maybe [livejournal.com profile] afuna or someone who knows the back-end better knows why, but I guess you can't re-cast a UserLite object like you can an EntryLite (print_entry() in Expressive re-casts the EntryLite argument into a Comment or Entry object, depending on the type). Even if the preceding were possible, this approach wouldn't work in most layers anyway, because they call print_entry() on Entry objects.

Profile

av8rmike: Futurama's Bender in Jeffries tube, text: I'm done reconfoobling the energymotron (Default)
av8rmike

November 2010

S M T W T F S
 123456
78910111213
14151617181920
21222324252627
28 2930    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 24th, 2017 02:05 pm
Powered by Dreamwidth Studios