?

Log in

No account? Create an account
[theme] - [boxer] - [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] - [boxer] - [mood icon to left of metadata] [Oct. 9th, 2005|12:09 am]
S2 Layers

s2layers

[kunzite1]
[Tags|, , ]

in response to stupid_thing's boxer_help post.
grab this, then the replace Entry::print_metadata() with the following...
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="metadata">"""; # 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     = """<strong>""";   # 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      = """<br />""";     # 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);
          }

          # 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: lovelymolecules
2005-10-09 07:28 pm (UTC)
I used this on one of my old Opal layouts, and I'd love to use it on one of my new Boxer ones, but I can't figure out where the Entry::print_metadata() is or what to do with all the coding. :/
(Reply) (Thread)
[User Picture]From: kunzite1
2005-10-09 07:35 pm (UTC)

then you fail at advanced customizations in s2?

i provided a link to another entry i made just minutes before this one that has function overrides for functions that deal with printing of entries.

the boxer layout has many things inside print_entry() that could be pulled out. like the metadata, comment links, and linkbar.

so. compare your version of print_entry() with the one in the previous entry. and then make sure you've got $e->print_metadata(); in it. then it'll call Entry::print_metadata(). if you have the code in this entry for your definition of Entry::print_metadata() you should get something similar to your desired effect.

those users who just copy and paste and don't read bug me. s2 is a programming language. you should at least have a small sense of how it works before you go asking questions when the code is right there for you.

yes. it's hard. but you have to learn. sometimes i'll be in a mood to do it all for you. sometimes i won't. this time is a won't. there are resources out there that will teach you how to use the language. such as this at component_help. give it a spin. once you grasp the concept of layers, this will get easier to understand.

my main annoyance is the lack of official documentation for the novice users who want to use the advanced customizations.
(Reply) (Parent) (Thread)
[User Picture]From: lovelymolecules
2005-10-09 08:23 pm (UTC)
I'm sorry to have annoyed you, but thank you for your help. Like you said, it is very hard to learn S2, and requires a lot of time, which I haven't had a whole lot of lately.

The only thing that really had me confused was the connection between the two pieces of code, but I think you explained that in your comment.

Again, I'm sorry that I annoyed you, I completely understand where you're coming from. But hey, we all have to start learning somehow, right?
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2005-10-09 08:29 pm (UTC)

it's ok. s2 takes time to get the hang of. i just have the mind for it.

several people who were utterly confused when they started eventually got the hang of it.

unfortunately, there are others who are still completely lost.

if i answered your question, awesome.
if not, ask again and i'll see if i can explain it better.
(Reply) (Parent) (Thread)
[User Picture]From: kiptrip
2005-11-17 09:18 am (UTC)
Hiya,

Thanks a ton for the code. It works great except I don't want the tags to show below Mood and Music (I already have them showing at the top of my posts). How do I edit this code to get rid of the tags?

Hope you can help, thanks so much.
(Reply) (Thread)
[User Picture]From: kunzite1
2005-11-17 09:20 am (UTC)

remove the section that talks about tags?
(Reply) (Parent) (Thread)
[User Picture]From: kiptrip
2005-11-17 09:25 am (UTC)
Duh! Got it, thanks! :)
(Reply) (Parent) (Thread)
[User Picture]From: kunzite1
2005-11-17 09:27 am (UTC)

yep.
(Reply) (Parent) (Thread)
[User Picture]From: sourfall
2006-03-22 04:14 am (UTC)
Thanks for this; very swank-looking! :D
(Reply) (Thread)
[User Picture]From: imagineforever
2006-05-10 12:36 pm (UTC)
These codes are awesome, they worked like a charm. But I'd like to change the font size and move all the meta down a row or two away from my entry. Could you help me with this?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-05-11 08:01 am (UTC)

.metadata {
  font-size:    7pt;
  padding-top: 10px;
}
(Reply) (Parent) (Thread)
[User Picture]From: imagineforever
2006-05-11 11:52 am (UTC)
Works perfect, and you are awesome. Thanks so much! :D
(Reply) (Parent) (Thread)
[User Picture]From: giina
2006-06-10 04:49 pm (UTC)
Thanks so much for the code. However, the comment bar seems to be messed up.



I haven't altered the code any. Any ideas?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-06-10 06:21 pm (UTC)

that's the linkbar. it's controlled by Entry::print_linkbar() and not Entry::print_metadata().
(Reply) (Parent) (Thread)
[User Picture]From: forgiveninasong
2007-02-06 12:37 am (UTC)
Okay, I am going to be really dumb.

I'm not using your codes, I am using likedoves, which it seems totally impossible to find any customisation for. But, I seem to work really well with these codes and find it the easiest.

If I made my layer public, do you think you would be able to take a look at it and give me a nice little gentle shove in the right direction as to where I would be able to put the customisation that you put above?

It would mean a lot to me!

xxx
(Reply) (Thread)
[User Picture]From: forgiveninasong
2007-02-06 12:48 am (UTC)
Okay, if you get a chance..

Layer is set to viewable. Layer id is 6269649.

Thanks!

xxx
(Reply) (Parent) (Thread)