The S2 HowTo Journal

Tips, Tricks, and Tutorials for Basic S2 Customization

Previous Entry Share Next Entry
[paidaccount][opal] Renaming 'Edit Entry', 'Edit Tags' and 'Add to Memories' links
howto_user wrote in s2howto
Paid Accounts Only
The 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.

This tutorial describes how you can change the wording of the 'Edit Entry', 'Edit Tags', 'Add to Memories', 'Share This!', 'Track', 'Untrack' and 'Flag' links in Opal (Libra OSWD). It will replace the function Page::print_entry (Entry e). This new code will be placed in a theme layer. If you already have a theme layer for this style, you can simply edit it. If not, you will need to create one by following the instructions in the Theme Layer tutorial.

You will need to copy the function Page::print_entry (Entry e) to your theme layer. At the Public Layers page, select Opal (Libra OSWD). Click "Raw Source Code" when viewing a style to download the S2 source. Then locate and copy all of the Page::print_entry (Entry e) into the layer edit window for your theme layer. This function contains a lot of code to handle user icons, moods, and other formatting, and it will be like the following code:

function Page::print_entry (Entry e)  {

    print """<a name="item""" + $e.itemid + """\"></a>""";
    var string time = $e.time->time_format();
    var string date = $e.time->date_format();
    var string security;
    if ($e.security != "") {
        $security =  """<img src="$e.security_icon.url" align="right" """+
        """width="$e.security_icon.width" height="$e.security_icon.height" """+
        """alt="[$e.security]" />""";
    }

    var UserLite name;
    var string pname;

    var bool show_name = ($.view == "friends" or $e.poster.username != $.journal.username or $.view == "entry") ? true : false;
    var bool show_pic = (defined $e.userpic and ($.view == "friends" or $*show_entry_userpic or $e.poster.username != $e.journal.username or $.view == "entry")) ? true : false;




    """
                                    <div class="entry">
                                        <div class="entrydivider"></div>
    """;
    if($show_pic) {
        """
            <div class="userpic2">
                <a href="$*SITEROOT/allpics.bml?user=$e.poster.username"><img src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" alt="$e.poster.name [userpic]" title="$e.poster.name [userpic]" border="0" /></a>
            </div>
        """;
    }

    if($show_name) {
        $this->lay_make_username($e);
    }
    """
                                        <div class="entryinfo">$security $date $time</div>
                                        <div class="entrydivider"></div>
                                        <div class="entrylinks">
    """;

    $e.comments->print();

    var Link link;
    foreach var string key ($e.link_keyseq) {
        $link = $e->get_link($key);
        if (defined $link) {
            """<a href=\"$link.url\"> &nbsp; $link.caption &nbsp; </a>""";
            $link->print_raw();
        }
    }
    """<a href="$e.permalink_url"> &nbsp; $*text_permalink &nbsp; </a>
                                        </div>
                                        <div class="entrytext">
                                            <div class="subject">$e.subject</div>
    """;
        "<p>"; $e->print_text(); "</p>";

    $e->print_metadata();

    """
                                        </div>
                                    </div>
                                    <div class="backtop"><a href="#top">back to top</a></div>

    """;
}

Within the function Page::print_entry (Entry e) locate the following block of code, which makes the various links:

    var Link link;
    foreach var string key ($e.link_keyseq) {
        $link = $e->get_link($key);
        if (defined $link) {
            """<a href=\"$link.url\"> &nbsp; $link.caption &nbsp; </a>""";
            $link->print_raw();
        }
    }

You will need to replace it with the following code, changing the words highlighted in orange to the words you wish to have for the links instead.

    var string{} my_captions = {"edit_entry" => "Edit Entry",
                              "edit_tags" => "Edit Tags",
                              "mem_add" => "Add to Memories", 
                              "tell_friend" => "Share This!",
                              "watch_comments" => "Track",
                              "unwatch_comments" => "Untrack",
                              "flag" => "Flag",};
    var Link link;
    foreach var string key ($e.link_keyseq) {
        $link = $e->get_link($key);
        if (defined $link) {
            var string caption = defined $my_captions{$key} ? $my_captions{$key} : $link.caption;
            """<a href=\"$link.url\"> &nbsp; $caption &nbsp; </a>""";
            $link->print_raw();
        }
    }

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.

Written by camomiletea.


Comments Disabled:

Comments have been disabled for this post.

?

Log in

No account? Create an account