How Random Babbling Becomes Corporate Policy (t3knomanser) wrote in component_help,
How Random Babbling Becomes Corporate Policy
t3knomanser
component_help

  • Music:

Scrolling Entries - Not a Scrolling Entry Page

Someone forget their LJ cut and post two hundred lines of whiny tripe that you'd rather skip? Unfriend them! Or, with a small mod based off of masterslacker's customizing of the entries, you can make every entry a fixed height and width, with a scroll bar per entry.

An important variable for this is maxLength, which is a number of characters. If an entry exceeds this number of characters, the auto resizing kicks in, and locks it to a specific height, and adds a scrollbar. FYI: the average word length is 6, so 6 * n is roughly n words. Also, remember that images are only a small amount of text (<img src="url" height="x" width="y" alt="some text">), so an image-only post probably won't start scrolling.

You may need to tweak things slightly (or use stylesheet classes) to get it exactly right.

### Override the printing of entries. This affects the Recent/Day pages, Friends pages, and Entry pages.
function print_entry(Page p, Entry e, Color bgcolor, Color fgcolor, bool hide_text) {
  var int maxLength = 100*6;#some value... I like 600 because that's roughly 100 words
  # Print the header for the entry. It prints in the default form "[<icon> ]<time> <date>" where:
  #   <icon> is the security icon (ie. lock if protected, eye if private, or none if public)
  #   <time> is in the default time format (eg: 03:46 am)
  #   <date> is bold and in the "long" format (eg: November 25th, 2003)
  # The ordering can be adjusted however needed, and you can also modify the formats that date and time print in.
  # This can all be done in the red section below. For specifications of available formats or how to construct
  #   your own formats, you can see: http://www.livejournal.com/doc/s2/siteapi.core1.html#siteapi.core1.dateformats
  """<div style="width: 650px;">""";
  print_entry_header((defined $e.security_icon?"$e.security_icon   ":"")+$e.time->time_format()+" <b>"+$e.time->date_format("long")+"</b>");

  # This is where we begin the main section of the entry, ie. the "entry background"
  # I was trying to use print_system_box_top(), but the code it generated didn't seem to match up with the page source. 
  # I was having some problems with the usericon being displayed as well, so I just decided to write my own.
  """
  <table cellspacing="0" cellpadding="0" border="0" width="100%">
    <tr>
      <td width="1" colspan="3" class="dkLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
    </tr><tr>
      <td width="1" class="dkLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
  """;

  # Check to see if we need to display a usericon and/or journal names, and if so, then print them
  # Cases - 1. We are viewing a friends page, so we need to display icons if they exist and journal/poster names
  #         2. We are viewing a recent/day/entry page, so we display only the icon if it exists and 
  #            the user has set recent userpics on.
  # The code in red is the logic to decide whether or not to show the userpics. You can modify it as you see fit.
  if ($p.view=="friends" or ($*show_entry_userpic and defined $e.userpic) or $e.journal.journal_type=="C") { 
     # Start the table that will hold the icon and/or names
     """
     <td class="entryHolderBg" valign="top">
     <table cellspacing="0" cellpadding="0" border="0" align="center">
       <tr>
         <td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
       </tr>
     """;
     # Display the icon if it exists
     if (defined $e.userpic) { """
       <tr>
         <td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="2" alt="" border="0" /></td>
         """;
         # If we are on the friends view, then we want to print the extra border around the image that have the colors
         # which are custom defined. If you don't like the colors or the border on the friends view, then you can just
         # remove the blue segments. By default the recent/day/entry pages have a border around the usericons. If a user
         # has a non-rectangular image, this may look strange, so you can replace the 1 with a 0 to remove the border.
         # 
         if ($p.view=="friends") { 
            """ <div style="padding-top: 3px; padding-left: 3px; padding-right: 3px; padding-bottom: 3px; background-color: """; print $bgcolor.as_string; """ ;" align="center">
            <img border="1" src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" alt="" style="border-color: """; print $fgcolor.as_string; """ ;" />
            </div> """;
         }else{
            """ <td align="center" class="userpic"><img border="1" src="$e.userpic.url" width="$e.userpic.width" height="$e.userpic.height" alt="" /></td> """;
         }
         """
       </tr>
     """; }
     # Display the journal and possibly poster name if we are viewing the friends page or any page on a community
     # This code will print the journal the entry was made on, and if the poster is different, will print the poster under it.
     # I made the names centered under the image, but if you want to keep them left aligned as in the original, then
     # remove the blue segments
     if ($p.view=="friends" or $e.journal.journal_type=="C") { """
       <tr>
         <td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="2" alt="" border="0" /></td>
         <td align="center" class="ljuser">$e.journal""";
         if ($e.journal.username!=$e.poster.username) {"""
           <div align="center" class="ljuser">$e.poster</div>""";
         } """
         </td>
       </tr>""";
     }
     """
     </table>
  """; }

  # Start the main entry text area
  #   The first line is needed because I did not use print_system_box_top() as stated above
  """<td class="entryHolderBg" width="100%" valign="top">""";
  print_content_top();

  # If the subject is not empty, then print it followed by the line to seperate it from the entry text
  if ($e.subject!="") { """
        <div class="entryHeader">$e.subject</div>
        <div class="entryDash"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></div>
      </td>
      <td width="1" class="medLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
    </tr>
    <tr>
      <td width="1" class="medLine"><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="1" alt="" border="0" /></td>
      <td class="entry"><
  """; }
  if ($e.text->length() > $maxLength) {
     """<div style="height: 250px; widthL 545px; overflow: auto;">""";
  } else {
     """<div style="width: 545px; overflow: auto;">""";
  }

  # Print the entry text.
  # If you want the entry text to be after the mood and music, then you need to do two things:
  #  - decomment the pink lines by removing the #'s from in front of them
  #  - comment out the blue lines by putting a # in front of them
  """ $e.text """;

  # Print Mood and/or Music Fields:
  # If we have a mood to print
  if ($e.metadata{"mood"}!="") { 
    # first we need a spacer after the entry text
    """<br/><br/>""";
    # and then we print the mood label and the mood
    """<b> $*text_meta_mood : </b>"""; print $e.metadata{"mood"}; 
    # followed by the mood icon if one exists. If you don't want the mood icons to show, remove the line below
    if (defined $e.mood_icon) { """ $e.mood_icon """; }
    """<br/>""";
    # if ($e.metadata{"music"}=="") { """<br/>"""; }
  }
  # If we have music to print
  if ($e.metadata{"music"}!="") { 
    # If we didn't print a spacer because the mood was empty, then print one
    if ($e.metadata{"mood"}=="") { """<br/><br/>"""; }
    # then print the actual music label and the music
    """<b> $*text_meta_music : </b>"""; print $e.metadata{"music"};
    # """<br/><br/>""";
  }

  # """ $e.text """;
  
  # Close off the entry text area
  """</div>""";
  print_content_bottom();

  # This is where the fun stuff is!
  # Now we begin the area underneath the entry that holds the comments, link, and entry related buttons.
  """
  <table width="100%">
    </tr>
      <td width="40%" align="left" valign="center">
        <div class="entryComments">
        """;
        # First we print the comment links if the entry allows comments
        if ($e.comments.enabled) {
          $e.comments->print();
        }
        """
        </div>
      </td>
      <td width="20%" align ="center" valign="center">""";
        # Then print a permanent link to the entry. 
        # I have this because I have my journal set to display comment links with "?nc=XX" tacked onto the end,
        # and when I'm copying and pasting links, it's annoying to have there. Also, if you want a link to
        # an entry that has no comments yet, the only link that's shown by default is the reply to link, and that
        # that includes "?mode=reply" which is also annoying to have to remove.
        # Essentially this is here for convenience. If you don't want it, remove the blue segment.
        """
	<div class="entryComments"><b>( <a href="$e.permalink_url" class="commentLinks">$*text_permalink</a> )<b></div>
      </td>
      <td width="40%" align ="right" valign="center">""";
        # Then the entry related buttons
        """<div class="entryComments">
          """;
          # The easiest way to do this, which will work for all account types, is as follows, and will display actual buttons. 
          # I used to use the code following it, but ran into problems trying to figure out the logic to show the edit button on a community properly. 
          # If you'd like text instead of buttons, then you can remove the following line in blue, decomment the lines in pink,
          # and edit as you see fit. Note that using the print_linkbar function will also add next and previous buttons when viewing using the EntryPage. 
          $e->print_linkbar();
          
          # Edit button : Only put up if the person viewing this entry wrote the entry
          # I check that by checking whether the person looking at the page is the owner of the page, and the entry's poster is the page's owner.
          # It puts Edit buttons on my entries, and entries that I post to communities that show on my friends page.
          #if (viewer_is_owner() and $e.poster.username==$p.journal.username) { """
          #  <a href="http://www.livejournal.com/editjournal_do.bml?journal=$e.journal.username&itemid=$e.itemid">
          #      <img border="0" width="22" height="20" alt="Edit Entry" src="http://stat.livejournal.com/img/btn_edit.gif" /></a>
          #  """;
          #}"""
          #<a href="http://www.livejournal.com/tools/memadd.bml?journal=$e.journal.username&itemid=$e.itemid">
          #    <img border="0" width="22" height="20" alt="Add to Memories" src="http://stat.livejournal.com/img/btn_memories.gif" /></a>
          #<a href="http://www.livejournal.com/tools/tellafriend.bml?journal=$e.journal.username&itemid=$e.itemid">
          #    <img border="0" width="22" height="20" alt="Tell A Friend" src="http://stat.livejournal.com/img/btn_tellfriend.gif" /></a>""";
        """
        </div>
      </td>
    </tr>
  </table></div>
  """;

  # End the entry component and put a spacer after it so that entry components are seperated.
  print_system_box_bottom();
  """ <div><img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="3" alt="" border="0"></div> """;

} # end of Function print_entry


Enjoy.
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 37 comments
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →
Previous
← Ctrl ← Alt
Next
Ctrl → Alt →