Paid Members: Add Subject Line to Single Entry View

Mar 21, 2012 15:59

So you've got your layout all beautified through the use of CSS and possibly some theme layer code poking, right? And then you click on an entry and realize that the subject line is just... not there. I've been there. I've figured out that futzing with the CSS of .bodyheaderblock will show a subject line -- but not the same one as shows in the recent/friends views on your journal. Well! After angsting for basically forever about how .bodyheaderblock just doesn't look the same, I scrolled through the Smooth Sailing base code and decided to experimentally copy/paste something in my theme layer. And it worked. So now I'm sharing said experimental copypasta with you fine people.

This is the original code for the subject line in Smooth Sailing layouts. Copy and paste it, in its entirety, into your theme layer:

function Entry::lay_print_subjectline(Color bg, Color fg, bool usecolour) {
       var Page p = get_page();
        if (($.itemid!=int($*layout_guestbook_entryid) or ($.delayed))) {
          """
""";
          if ($p.view!="day") {
            # print " base_url()+"/calendar/$.time.year/"+zeropad($.time.month,2)+"/"+zeropad($.time.day,2)+"/\">"+$.time->date_format("%%dayord%%")+"-";
            # print " base_url()+"/calendar/$.time.year/"+zeropad($.time.month,2)+"/\">"+$.time->date_format("%%mon%%")+"-";
            # print " base_url()+"/calendar/$.time.year/\">"+$.time->date_format("%%yyyy%%")+" ";
            # print $.time->time_format();
            print $.time->time_format($*text_format_entry_date_and_time);
          }else{
            # print $.time->time_format();
            print $.time->time_format($*text_format_entry_time);
          }
          """""";
          if ($p.view=="entry") {
            if ($.delayed) { " - $.delayed_icon"; }
            if ($.sticky) { " - $.sticky_icon"; }
            if (defined $.security_icon) { " - $.security_icon"; }
          }else{
            print (defined $.security_icon or $.sticky or $.delayed or $.subject!="" ? " - " : "");
            if ($.delayed) { "$.delayed_icon "; }
            if ($.sticky) { "$.sticky_icon "; }
            if (defined $.security_icon) { "$.security_icon "; }
            print $this->formatted_subject({"class"=>"subj-link"});
          }
          """""";
          if ((size $.tags>0)and($*layout_position_entrytags=="subject")) {
              """ [ $.tags[0].name""";
              foreach var int i (1 .. (size $.tags - 1)) {
                  """, $.tags[$i].name""";
              }
              """]""";
          }
          """""";
        }else{
          """
""";
          if (defined $.security_icon or $.sticky or $.delayed) {
            if ($.delayed) { "$.delayed_icon "; }
            if ($.sticky) { " $.sticky_icon "; }
            if (defined $.security_icon) { " $.security_icon"; }
          } else {
            " ";
          }
          """""";
        }
}

What we're concerned with, to make your entry subjects matchy-matchy on recent and single entry views, is the following chunk of code from this function:

if ($p.view=="entry") {
            if ($.delayed) { " - $.delayed_icon"; }
            if ($.sticky) { " - $.sticky_icon"; }
            if (defined $.security_icon) { " - $.security_icon"; }
          }else{
            print (defined $.security_icon or $.sticky or $.delayed or $.subject!="" ? " - " : "");
            if ($.delayed) { "$.delayed_icon "; }
            if ($.sticky) { "$.sticky_icon "; }
            if (defined $.security_icon) { "$.security_icon "; }

See how the two sections don't match? Well, we can fix that. Hit enter after if ($p.view=="entry") { and add:

print (defined $.security_icon or $.sticky or $.delayed or $.subject!="" ? " - " : "");

Then compile your layer and bask in your new, matchy-matchy entry subjects.

I hope this wasn't confusing for anyone! It's been literally years since I've written a tutorial like this.

tips, subject bar, tutorial, layers

Previous post Next post
Up