?

Log in

[theme] - [opal] - [mood icon to left of metadata] - S2 Layers [entries|archive|friends|userinfo]
S2 Layers

[ website | advanced customization ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Links
[Links:| how to post tags page ]
[affiliated communities| fblayers ]

[theme] - [opal] - [mood icon to left of metadata] [Feb. 24th, 2006|09:04 pm]
S2 Layers

s2layers

[kunzite1]
[Tags|, , ]
[music |Disco Dan - Mega Man 3 BlueLightning OC ReMix]

# add colons because hard-coding it is silly
set text_meta_location = "Current Location:";
set text_meta_mood     = "Current Mood:";
set text_meta_music    = "Current Music:";

function Entry::print_metadata() {
  var string tags_header         = "Current Tags"; # text for tags header,    "Current Tags"
  var string tags_joiner         = ":";            # text for tags joiner,    ":"
  var string tags_sep            = ", ";           # text for tags separator, ", "
  var bool   show_edit_tags_link = false;          # set to true if you want edit tags link as tags header

  var string currents_open       = ""; # html for opening of currents container
  var string currents_close      = ""; # html for closing of currents container

  var bool   loc_after_mood      = false;               # set to true to print location after mood
  var bool   vanilla_loc         = false;               # set to true to delinkify location

  # if you need data specific to the meta to be in these strings you'll have to set those individually down further
  # one example is provided with meta_label_open
  var string meta_label_open     = """<div class="meta">""";   # html for opening of metadata label
  var string meta_label_close    = ""; # html for closing of metadata label
  var string meta_val_open       = " ";               # html for opening of metadata value
  var string meta_val_close      = """</div>""";     # html for closing of metadata value

  var Link   edit_tags           = $this->get_link("edit_tags"); # helper var to see if remote user can edit tags

  if ((size $.metadata > 0) or ((size $.tags > 0) and ($*tags_aware))){
    if($.metadata{"mood"} == "" and $loc_after_mood) {
      # if we're printing loc after mood but we have no mood, set loc_after_mood to false
      $loc_after_mood = false;
    }
    var string currents = "";             # make var for printing
    $currents           = $currents_open; # add opening of currents container

    if(defined $.mood_icon) {
      var Image i = $.mood_icon;
      $currents = $currents + """<table border="0"><tr><td><img src="$i.url" width="$i.width" height="$i.height" alt="$.metadata{"mood"}" title="$.metadata{"mood"}" /></td><td>""";
    }

    foreach var string k ($.metadata){  # step thru metadata
      var string text = $k;             # set text to key
      var string val  = $.metadata{$k}; # get val
      if ($k == "mood"){                # if mood, set text to mood property
        $text = $*text_meta_mood;
      } 
      elseif ($k == "music") {          # if music, set text to music property
        $text = $*text_meta_music;
      } elseif ($k == "location") {     # if location, set text to loc variable
        $text = $*text_meta_location;
        if($vanilla_loc) {              # if vanilla loc, striphtml() it
          $val = striphtml($val);
        }
      }
      if(not ($k == "location" and $loc_after_mood)) {
        # if we're doing loc right now and printing loc after mood, skip it
        # if we're doing loc right now and we're not printing loc after mood, print it now
        # if we're not doing loc right now, print this piece of meta

        # add the meta
        $currents = $currents + """$meta_label_open$text$meta_label_close$meta_val_open$val$meta_val_close""";
      }

      if($k == "mood" and $loc_after_mood) {
        # if we just now did the mood and we're printing loc after mood, print the loc
        $k    = "location";           # set meta key to "location"
        $text = $*text_meta_location; # set text to loc variable
        $val  = $.metadata{$k};       # get val

        # if we have a loc, do stuff
        if($val != "") {

          # if vanilla loc, striphtml() it
          if($vanilla_loc) {
            $val = striphtml($val);
          }

          # in this layout, each piece of meta gets its own class
          $meta_label_open  = """<div class="current$k"><strong>""";

          # add the meta
          $currents         = $currents + """$meta_label_open$text$meta_label_close$meta_val_open$val$meta_val_close""";
        }
      }
    }
    if ((size $.tags > 0) and $*tags_aware) {
      var string k      = "tags"; # set key to "tags"

      var int tcount = 0; # set counter for tags
      if($edit_tags.url != "" and $show_edit_tags_link) { # if remote user can edit tags, let's give them a link
        $tags_header = """<a href="$edit_tags.url">$tags_header</a>""";
      }

      # add text, open val container
      $currents = $currents + """$meta_label_open$tags_header$tags_joiner$meta_label_close$meta_val_open""";

      # build tag list
      foreach var Tag t ($.tags) {
        $currents = $currents + """<a rel="tag" href="$t.url">$t.name</a>""";
        $tcount++;

        # if we haven't hit the last tag, add a separator
        if ($tcount != size $.tags) { $currents = $currents + $tags_sep; }
      }

      # close val container
      $currents = $currents + $meta_val_close;
    }

    if(defined $.mood_icon) {
      $currents = $currents + """</td></tr></table>""";
    }

    # close currents container
    $currents = $currents + $currents_close;

    # print currents
    println "$currents";
  }
}
linkReply

Comments:
[User Picture]From: replica
2006-04-20 07:51 pm (UTC)
I'm really confused. Being S2 stupid, I have no idea what I'm doing. How do I remove the tags from that? Because now I have my tags listed at the top and the bottom, and I already liked them listed at the top...
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-21 05:24 am (UTC)

so, i guess you got it figured out by the other post you made?
(Reply) (Parent) (Thread)
[User Picture]From: replica
2006-04-21 05:28 am (UTC)
yeah, sorry. I realized after I posted the comment I had other stuff I wanted to ask about and I figured it wouldn't hurt to throw that in too, while I was at it.
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-04-21 05:32 am (UTC)

good to know that you got part of it figured out.
(Reply) (Parent) (Thread)
[User Picture]From: carnifinda
2006-05-01 12:58 pm (UTC)
Wanna know something? I love you. And this works with smooth sailing as well, yay!
(Reply) (Thread)
[User Picture]From: kunzite1
2006-05-01 02:41 pm (UTC)

this exact format won't apply the same formatting, but, if you alter some of the settings at the top, it should reinstate the proper css handles for the meta.
(Reply) (Parent) (Thread)
[User Picture]From: carnifinda
2006-05-02 04:27 pm (UTC)
That's what I did. And it worked perfectly well :)
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-05-02 06:56 pm (UTC)

excellent. :D
(Reply) (Parent) (Thread)
[User Picture]From: the_sweet
2006-06-15 11:15 pm (UTC)
Which settings did you edit? I'm using Smooth Sailing right now, and I'm not used to hard-coding anything, so I'm not even sure where to begin so I don't fudge everything up.
(Reply) (Parent) (Thread)
[User Picture]From: solookup
2006-05-28 11:06 am (UTC)
I was looking at the code to see if I could link the Current Tags: to the Edit Tags page and saw that it already had the "a href" part, but still no links shows up on the page.

Did I do something wrong or is something else happening?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-05-28 11:08 am (UTC)

  var bool   show_edit_tags_link = false;          # set to true if you want edit tags link as tags header
(Reply) (Parent) (Thread)
[User Picture]From: solookup
2006-05-28 11:10 am (UTC)
Oh geez, thanks! I think that's a sign for me to go to sleep...
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2006-05-28 11:10 am (UTC)

i should too... z_z
(Reply) (Parent) (Thread)
[User Picture]From: beetwo
2006-06-04 03:21 am (UTC)
This worked wonderfully. I wanted to edit the whole "current location" and this was exactly what I needed. Thank you!
(Reply) (Thread)
[User Picture]From: mangle
2006-06-05 02:57 am (UTC)
This is great, but now I have tags with the metadata and underneath the subject. Anyway of removing it from the currents?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-06-06 10:17 am (UTC)

here's a hint:
if ((size $.tags > 0) and $*tags_aware) {
(Reply) (Parent) (Thread)
[User Picture]From: comewhatmay
2006-07-31 03:00 am (UTC)
I'm using halffling's codes, and since the tags are already at the top, it shows twice. I tried looking at the "if ((size $.tags > 0) and $*tags_aware) {" part but I honestly don't know what you mean.

and I also can't get the "Feeling" "Listening To" parts to bold.

Other than that you're a genius and i can't thankyou enough!
(Reply) (Thread)
[User Picture]From: kunzite1
2006-08-02 06:32 pm (UTC)

remove the block that talks about tags.

change meta_label_open from <div class="meta"> to <div class="meta"><b> and meta_label_close to </b>.
(Reply) (Parent) (Thread)
[User Picture]From: forgiveninasong
2007-02-06 12:29 am (UTC)
Will this be able to work in The Boxer? I tried to put it into my codes, but it only seemed to make my LJ blank and not show up in my broswer, although it complied with no problems :/

Meh.

xxx
(Reply) (Thread)
[User Picture]From: forgiveninasong
2007-02-06 12:32 am (UTC)
Neeeever mind! Found the Boxer one. Man, if only I looked hard enough to start off with!

xxx
(Reply) (Parent) (Thread)
[User Picture]From: whatsername_31
2007-03-15 05:24 am (UTC)
Perfect!

I had to do a bit of thinking since I am still working on learning coding, but I did it, and it is brilliant!

Thanks:-D
(Reply) (Thread)
[User Picture]From: purecashmere
2007-03-26 12:05 pm (UTC)
Hehe I discovered the fun of Opal only a couple of days ago and I must say; You're my hero ^__^
(Reply) (Thread)
[User Picture]From: dorkdance
2007-05-22 06:38 pm (UTC)
Okay, so either I'm being computer-stupid today or something has happened to Opal since you wrote this tutorial, because whenever I remove the tags block it gives me compiling errors. I'm betting on the computer-stupid thing, though. :| Help?
(Reply) (Thread)
[User Picture]From: denorios
2010-03-27 10:23 pm (UTC)
I'd love to use this, but whenever I do my moodpic disappears. Everything is aligned as though the picture was there, but no image. Have LJ done something to Opal?
(Reply) (Thread)