?

Log in

No account? Create an account
[theme] - [flexisquares] - [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] - [flexisquares] - [mood icon to left of metadata] [Dec. 13th, 2005|06:47 pm]
S2 Layers

s2layers

[kunzite1]
[Tags|, , ]

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       = """<div class="clear">&nbsp;</div>
            <div class="clear">&nbsp;</div>
	    <div class="currents">"""; # html for opening of currents container
  var string currents_close      = """</div>"""; # 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     = "";               # html for opening of metadata label
  var string meta_label_close    = """</strong> """; # 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

        # 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($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"

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

      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: xtomxfallsx
2005-12-14 03:47 am (UTC)
Now do this for Component. :) I'm too lazy to do it myself.
(Reply) (Thread)
[User Picture]From: kunzite1
2005-12-14 03:48 am (UTC)

ha!

"bitch! get to work!"

will do.

XD
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: gatsby
2006-01-02 12:47 am (UTC)
God I love you.
(Reply) (Thread)
[User Picture]From: choose
2006-02-12 04:26 am (UTC)
I'm using this now, thanks alot. Oh um, is there anyway to include the tags? As in, beside the mood icon?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-02-12 04:28 am (UTC)

you need to tell the layout to be aware of tags.
set tags_aware = true;
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: _charon
2006-04-01 12:55 pm (UTC)
Is there a way to include the location in this code?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-01 06:48 pm (UTC)

fun. seems that i get to update all the entries with Entry::print_metadata() in them now...
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: tajasel
2006-04-07 05:22 pm (UTC)
sorry, I'm shit. where would this go in <a href="http://www.livejournal.com/customize/advanced/layersource.bml?id=6323419£>my layer</a>?
(Reply) (Thread)
[User Picture]From: poulpette
2006-04-20 03:05 pm (UTC)
Hmmm, Hi!

I wish to use thisin my future Flexible square layout but I'd like to have the tags at the top of the list instead if it is possible. I've attempted to move
the code the following code
    if ((size $.tags > 0) and $*tags_aware) {
      var string k      = "tags"; # set key to "tags"

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

      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;
    }

above this line if(not ($k == "location" and $loc_after_mood)) but it resulted in the tags being written three times.

Could you please give me a hand with this?

My theme layer is here, and this part of the code is at the bottom of it.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-21 08:51 pm (UTC)

put that block above foreach var string k ($.metadata){
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: ausoleil
2006-04-21 01:17 am (UTC)
Hi! Is there any way to move the location to the bottom of mood and music, instead of only under mood? Because I'd like the metatada to be ordered like mood -- music -- location -- tags... is it possible?

Thanks you! :)
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-21 08:38 pm (UTC)

this specific function is for putting the mood icon to the left. do you want that?

if you want that specific order, it's not very easy to do and still have the logic work how i have it.

you'll have to completely restructure it. it'd make it simpler, but not expandable if new metadata members are added.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: lovenote
2006-04-24 01:05 am (UTC)
i got this all to work fine but i was wondering how i can get to have my tags right above my mood like crashfancy. do you know how i can do this? thanks in advance.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-24 01:11 am (UTC)

you must be on crack because their tags are below their mood.

and you might try moving the code block that talks about tags to just before the one that talks about metadata. might do something.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: liltinggrace
2006-05-17 02:20 pm (UTC)
That is utterly fabulous! Thank you. :D
(Reply) (Thread)
[User Picture]From: chibisparx
2006-05-22 08:10 pm (UTC)
I have my tags displayed somewhere else - what do I have to do to the code to get rid of the tags in the metadata section (I've tried, but I keep failing miserably).

Thanks for any help.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-05-23 02:51 am (UTC)

remove from here:
    if ((size $.tags > 0) and $*tags_aware) {
to here:
      # close val container
      $currents = $currents + $meta_val_close;
    }
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: kentucka
2006-06-21 10:51 am (UTC)
I played around with this code last night, to include what ausoleil mentioned: having complete control over the order in which the metadata is displayed. so far, it's only on my LJ. since I'm not a mod, I'm not sure if it's ok for me to post this on s2flexisquares.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-06-21 07:48 pm (UTC)

i don't know what you're asking of me. could you state it in the form of a question? or what exactly are you trying to say?
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: comewhatmay
2006-06-27 05:32 pm (UTC)
this is the coding I'm using, I tried to just input the following...but got nothing. anything I need to add or remove to make it all work?
(Reply) (Thread)
[User Picture]From: comewhatmay
2006-06-27 05:39 pm (UTC)
yeah, nevermind. LOL thanks so much for this!! :D
(Reply) (Parent) (Thread)
[User Picture]From: lady_maethoriel
2006-07-02 01:02 pm (UTC)
This is very helpful, thank you! I just have one question; how do I change the size of the tags text?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-07-03 02:13 am (UTC)

they're the same size as links.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: annadelko
2009-10-17 12:21 pm (UTC)
There's any way to change that in Smooth Sailing style ?
Thanks in advance .
(Reply) (Thread)