Guess (lauren) wrote in component_help,

  • Mood:

Using Tags to Create Special Entries

Thanks to some help from xtomxfallsx (and a suggestion from kunzite1), I was able to modify aelana's tutorial on how to make "special entries". Instead of using the "mood" field to designate whether or not an entry would be "special", I used tags. Hopefully, I made this tutorial correctly, but if not, well, sorry!

As is the case with the original tutorial, this code has a few limitations. I only wanted to make hidden entries, so I didn't play around much with the creation of "announcements". As a result, I don't know how to customize it as much as I would like to, but maybe in the future I'll get around to toying with it. Anyway, please make note of the following:

- formatting does not carry over to ReplyPage or EntryPage, so any special annoucements will be indistinguishable from regular entries & hidden entries will be visible
- people on your friends page will not see any of the special formatting, so unless you want the entries viewable from other people's friends pages, make sure the entry is backdated
- The special "announcement" entry type does not print any user information (including userpics & metadata), so it is likely that this code will need to be tweaked depending on who uses it

The tag names that you want to use to "activate" the special formatting can be set to whatever you want; I have indicated what you need to change in red. In the code, the two tags are "announcement" & "hidden". Hidden entries can be linked to explicitly, but will not be viewable on recent entries pages or day pages UNLESS you add the argument "?.unmask=true" to the end of the page URL. Announcement entries do not display a date; in the place where the date & security icon would be in a normal layout, the subject is there instead.

function Page::print_entry(Entry e) {
# If the page is a Recent Page or a Day Page do this
  if($this instanceof RecentPage or $this isa DayPage) {
      var Color fg;
      var Color bg;
      var bool tags_match = false;
      var bool tags_hide = false;

# Determines if tags are used in the entry and if the tags used are special
      if ((size $e.tags > 0) and $*tags_aware) {
        foreach var Tag t ($e.tags) {
	 if (($ == "announcement") and ($.args{"unmask"} != "true")) {
 	   $tags_match = true;
	 if (($ == "hidden") and ($.args{"unmask"} != "true")) {
	   $tags_hide = true;

# Prints the entry in the announcement format if the appropriate tag was used and unmask=false
        if ($tags_match == true) {
           print $e.text;
           if ($e.comments.enabled) {
              """<div class="entryComments">""";
              if (not ($e.comments.count == 0)) {
                 """ """;
                 print $*comment_divider;
                 """ """;      

# Prints entries regularly unless the tag to hide entries was used or unmask=true        
        elseif (($tags_hide == false) or ($.args{"unmask"} == "true")) {
           print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);
       elseif (size $e.tags == 0) {
         print_entry($this, $e, $bg->Color("#ffffff"), $fg->Color("#000000"), false);

# If the page is a Friends Page print entries normally
  if($this instanceof FriendsPage) {
     var FriendsPage fp = $this as FriendsPage;
     print_entry($this, $e, $fp.friends{$e.journal.username}.bgcolor, $fp.friends{$e.journal.username}.fgcolor, false);

Edit: I fixed a bug that made entries without tags hidden.
Tags: admin: deprecated, user: paperstar

  • S2 Layout Previews

    Page types: RecentPage FriendsPage YearPage MonthPage DayPage EntryPage ReplyPage TagsPage…

  • poster search!

    Entry Poster Search by month: Search in: component_help for user: during: January February March…

  • Super Site Map (cont. cont.)

    Last Updated: July 29, 2006. An comprehensive list of the links found on the site, useful communities and journals and your own journal/scrapbook…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened