Modifying Linkbars to use Images

Aug 22, 2006 17:05

These function overrides will allow paid users to change the Entry and Comment linkbars to use image links instead of text links. The code must be placed into an active theme layer.

Please read the comments in green carefully, and only edit text in red. You must specify full urls for your images, or they will not show properly. The current urls are images from the Boxer layout, used as a working example. The key in front of each url says where it is used, and the names should be self-explanitory.



# Print the linkbar for Entries, using imgs for the links instead of text
function Entry::print_linkbar() {

# Set link img urls here. Replace the URLs in red with your own URLs.
var string{} link_img = {
"sign_guestbook" => "http://stat.livejournal.com/palimg/boxer/leave_comment.gif",
"post_comment" => "http://stat.livejournal.com/palimg/boxer/leave_comment.gif",
"read_comments" => "http://stat.livejournal.com/palimg/boxer/comment.gif",
"permalink" => "http://stat.livejournal.com/palimg/boxer/comment.gif",
"edit_entry" => "http://stat.livejournal.com/palimg/boxer/edit.gif",
"edit_tags" => "http://stat.livejournal.com/palimg/boxer/tags.gif",
"mem_add" => "http://stat.livejournal.com/palimg/boxer/memories.gif",
"tell_friend" => "http://stat.livejournal.com/palimg/boxer/mail.gif",
"watch_comments" => "http://stat.livejournal.com/palimg/boxer/track.gif",
"unwatch_comments" => "http://stat.livejournal.com/palimg/boxer/untrack.gif",
};

# Initialise variables for quick reply and print the start of the entry linkbar
var Page p = get_page();
var bool printqr = false;
"""

    """;

    # Print the post comment and read comment links, or special guestbook image if necessary
    if ($.comments.enabled) {
    if ($.itemid==int($*layout_guestbook_entryid)) {"""

  • """;
    }else{
    if ($.comments.count > 0 or $.comments.screened) {
    """

  • """;
    }
    $printqr = true;
    """
  • """; $p->print_reply_link({"img_url" => $link_img{"post_comment"}, "target" => "qr$.journal.username$.itemid", "reply_url" => $.comments.post_url}); """
  • """;
    }
    }

    # Print the permalink. If you want to remove the permalink from the linkbar, delete the next line.
    """

  • """;

    # Print the other links (edit, edit tags, add to memories, etc)
    var Link link;
    var string url;
    var string text;
    foreach var string link_key ($.link_keyseq) {
    $link = $this->get_link($link_key);
    $url = $link.url;
    $text = $link_img{$link_key} != "" ? "
    " : $link.caption;
    if (defined $link) {
    """
  • $text
  • """;
    }
    }

    # End the linkbar and print the quick reply container if necessary.
    """

""";
if ($printqr) { $p->print_reply_container({"class" => "quickreply_entry", "target" => "qr$.journal.username$.itemid"}); }
}
# end of Entry::print_linkbar()

# Print the linkbar for Comments, using imgs for the links instead of text
function Comment::print_linkbar() {

# Set link img urls here. Replace the URLs in red with your own URLs.
var string{} link_img = {
"reply" => "http://stat.livejournal.com/palimg/boxer/leave_comment.gif",
"parent" => "http://stat.livejournal.com/palimg/boxer/parent.gif",
"permalink" => "http://stat.livejournal.com/palimg/boxer/comment.gif",
"delete" => "http://stat.livejournal.com/palimg/boxer/delete.gif",
"screen" => "http://stat.livejournal.com/palimg/boxer/screen.gif",
"unscreen" => "http://stat.livejournal.com/palimg/boxer/unscreen.gif",
"freeze" => "http://stat.livejournal.com/palimg/boxer/freeze.gif",
"unfreeze" => "http://stat.livejournal.com/palimg/boxer/unfreeze.gif",
"watch" => "http://stat.livejournal.com/palimg/boxer/track.gif",
"unwatch" => "http://stat.livejournal.com/palimg/boxer/untrack.gif",
};

# Print the start of the comment linkbar
"""


""";
$this->print_reply_container({"class" => "quickreply_comment"});
}
# end of Comment::print_linkbar()

link bar, tutorial

Previous post Next post
Up