[paid accounts only] [Cuteness Attack] Adding Usericons to the Recent View

Feb 16, 2007 20:49


Paid Accounts OnlyThe following tutorial requires creating and editing a custom style, which in turn requires a paid, permanent, or early adopter account. Please read What are the paid account benefits? and How do I buy a paid account? to learn about the paid account benefits and how to buy a paid account.
Usericons are disabled by default on the Recent Entries view of Cuteness Attack, so this tutorial covers how to enable them. It will override the print_entry function. This requires the creation of a theme layer. If you already have a theme layer, you will need to edit it and add the code below. If you do not have a theme layer, you will need to create one by following the instructions in the Theme Layer tutorial.

Copy and paste the following code into your theme layer if you do not already have the print_entry code in your theme layer. If you already have this in your theme layer (for example, if you have already customised an aspect of how journal entries are printed using this function) then ignore this step.

# ------------------------------- # display an entry (all views ) # ------------------------------- function print_entry ( Page p, Entry e ) { # get date/time var string datetime; $datetime = $e.time->date_format($*date_format) + " | " + $e.time->time_format($*time_format); # get metadata var string metadata; if ( $e.metadata ) { foreach var string k ( $e.metadata ) { var string text = $k; var string val = $e.metadata{$k}; if ( $k == "mood" ) { $text = $*text_meta_mood; } elseif ( $k == "music" ) { $text = $*text_meta_music; } elseif ( $k == "location" ) { $text = $*text_meta_location; } if ( $k == "mood" and defined $e.mood_icon ) { var Image i = $e.mood_icon; $val = "
$val"; } $metadata = "$metadata\n$text: $val
"; } } # get any extra user info (if posting to community, etc) var string poster = ""; var string userpic = ""; if ( $p.view == "friends" or $p.journal_type == "C" or $e.poster.username != $e.journal.username ) { if ( $e.poster.username != $e.journal.username ) { $poster = " base_url() + "\" title=\"$e.poster.username\">$e.poster.username in base_url() + "\" title=\"$e.journal.username\" >$e.journal.username"; } else { $poster = " base_url() + "\" title=\"$e.poster.username\">$e.poster.username"; } $poster = "posted by: $poster"; if ( defined $e.userpic ) { $userpic = "

"; } } # print the entry now: print "
"; # print icon (if needed) if ( $userpic != "" ) { print "$userpic"; } print ""; if ( $e.security != "" ) { $e.security_icon->print(); print " "; } if ( $e.subject == "" ) { print "$*text_nosubject"; } else { print "$e.subject"; } print "
"; print ""; if ( $p.view == "entry" and $*show_entrynav_icons ) { var string item_link = ""; foreach var string key (["nav_prev","nav_next"]) { var Link link = $e->get_link($key); if ( $link ) { if ( $key == "nav_prev" ) { $item_link = $item_link + " lower() + "\">« " + $link.caption->lower() + " | "; } elseif ( $key == "nav_next" ) { $item_link = $item_link + " lower() + "\">" + $link.caption->lower() + " »"; } } } print $item_link; print "
"; } print "$datetime
"; print "$metadata"; if ( $poster != "" ) { print "$poster"; } print "
"; print "
"; $e->print_text(); print "\n"; print ""; print safe get_permalink($e.permalink_url); if ( $p.view != "entry" and $p.view != "reply" ) { print " | "; $e.comments->print(); } elseif ( $e.comments.enabled ) { print " | "; $e.comments->print_postlink(); } var Link tmp; if ( viewer_is_owner() and $p.view != "friends" ) { $tmp = $e->get_link("edit_entry"); print " | $tmp.caption"; } $tmp = $e->get_link("mem_add"); print " | $tmp.caption"; print "
"; print ""; print ""; }
Now, locate the } highlighted in orange, and cut and paste it at the end of the line in blue. That line will now read as follows:

$poster = "posted by: $poster"; }
Ordinarily, this style checks to see if a journal is not on the Recent view, and if this is true, it prints a userpic and "posted by: exampleusername". This amendment means that the style still checks that it is not the Recent view in order to display "posted by: exampleusername", but displays the userpic regardless of the view.

Compile your layer, and it's ready to use. You will need to apply your theme layer via the Customize interface in order for your changes to take effect.
Additional References:
  • What are the different S2 layer types?

  • Contributed by dandelion.

    userpics on recent entries, adding userpics, userpics, paid accounts only, - cuteness attack

    Previous post Next post
    Up