Guess (lauren) wrote in component_help,
Guess
lauren
component_help

Special Entries with Tags

Edit: I wrote a tutorial on how I figured out how to do this here.

Two days ago, I made a post asking about how to make "special" entries using tags instead of moods, as is the case with aelana's tutorial (which was written before the advent of tags on LJ). So, I played around with the code a bit & tried to figure out how to do it myself. I'm having some problems though.

Ok, I've figured out how to actually format the special entries using tags, however, I am getting duplicate entries showing up on my page. I know exactly why this is happening, but I don't know how to fix it. The problem is the foreach; basically, the function is printing the entry once for every tag on the entry. However, I cannot for the life of me figure out how to get this to work without using the foreach statement, since I am not a programmer at all. All I really want to be able to do is make hidden entries that can be linked to explicitly, the announcements I can do without. Help?

function RecentPage::print_entry(Entry e) {
  var Color fg;
  var Color bg;

  if ((size $e.tags > 0) and $*tags_aware) {
   foreach var Tag t ($e.tags) {
    if (($t.name == "announcement") and ($.args{"unmask"} != "true")) {
     print_entry_header("<b>$e.subject</b>");
     print_system_box_top();
     print_content_top();
     print $e.text;
     print_content_bottom();
    
    if ($e.comments.enabled) {
      """<div class="entryComments">""";
      if (not ($e.comments.count == 0)) {
       $e.comments->print_readlink();
        """ """;
        print $*comment_divider;
        """ """;      
      }
      $e.comments->print_postlink();
      """</div>""";
     }
     print_system_box_bottom();
     print_spacer();
    } 
    
    elseif ((not ($t.name == "hidden")) or ($.args{"unmask"} == "true")) {
     print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);
    }
   }
  }
 }
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 7 comments