Log in

No account? Create an account
[theme] - [component] - [mood icon to left of metadata] - S2 Layers [entries|archive|friends|userinfo]
S2 Layers

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

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

[theme] - [component] - [mood icon to left of metadata] [Dec. 14th, 2005|02:05 pm]
S2 Layers


[Tags|, , ]

in response to xtomxfallsx' comment on my s2layers post.
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     = """<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>""";

        # 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";

From: lavishing
2006-03-08 07:29 pm (UTC)


I'm quite new with getting a paid account and using component. Can you please point me to the right direction? I'm having trouble with looking for the right tutorial. Where do I paste this layer into, also?
(Reply) (Thread)
[User Picture]From: kunzite1
2006-03-08 09:19 pm (UTC)

Re: Sorry..

(Reply) (Parent) (Thread)
From: leighblack
2006-04-03 12:53 pm (UTC)
You're the man, k1! Thanks for taking all the time to fix all this stuff.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-03 02:31 pm (UTC)

you're welcome.

it'd be helpful to me if you could confirm that it all works correctly.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: _inzilbeth_
2006-04-03 09:57 pm (UTC)
Oh yes...you made this extremely easy! Thanks!!
(Reply) (Thread)
[User Picture]From: snowpenguin545
2006-04-16 09:59 pm (UTC)
I feel really stupid asking this, but I've been trying to get this to work for the past hour or so and the hour before that I was sorting through memories and such. Anyway, I can't seem to get this to change my layout. It comes up as saying that the code is perfectly fine, but then I don't see any changes. I'm pretty new to this, so it's probably something very easy, but I've missed it.
(Reply) (Thread)
[User Picture]From: kunzite1
2006-04-16 10:28 pm (UTC)

make sure the following is in the same layer:
set tags_aware = true;
(Reply) (Parent) (Thread) (Expand)
From: albionete
2006-12-02 02:05 am (UTC)
Where exactly does this go in the code? I just put it after the
layerinfo "type" = "theme";
layerinfo "name" = "Blah blah";
thing and nothing happened. x.x

Here is my number... thing: 7746956
Help? ;_;
(Reply) (Thread)
[User Picture]From: kunzite1
2006-12-02 05:20 pm (UTC)
the default entry function does not call this function.
you need the "Customizing the entries" Tutorial.
(Reply) (Parent) (Thread)
[User Picture]From: airealataiel
2007-04-06 06:18 pm (UTC)
Will you please help me? I've tried this over and over again and it's not working. I have the set tags_aware = true, so that's not the problem.

I have copied/pasted and tried putting it almost everywhere in my layer, and it won't work. When I got it in the right spot and it compiled without error, it still didn't change the appearance of my layout at all.

Please help!
(Reply) (Thread)
[User Picture]From: kunzite1
2007-04-06 06:20 pm (UTC)
by default, the component layout does not call Entry::print_metadata(). you'll need to find and use the "customizing the entries" tutorial found in component_help.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: bunniehops
2007-04-13 10:00 pm (UTC)
I'm having a hard time as well. I'm reading the comments to see if I have simliar questions. Most need the customizing entries tutorial. I can't seem to find it. I feel so stupid for asking this. I'm sure it's pretty easy.
(Reply) (Thread)
[User Picture]From: bunniehops
2007-04-13 10:08 pm (UTC)
Nevermind, I found it. I do have another question. I guess I need the "print_entry()" part. I cant seem to find it. I'm asking really easy questions, I'm sure, but I'm having a hard time.
(Reply) (Parent) (Thread) (Expand)
[User Picture]From: everglowed
2007-07-12 02:07 am (UTC)
I have the print entry part in my layout. I changed all the things to make it work but it still doesn't work.
(Reply) (Thread)
[User Picture]From: kunzite1
2007-07-13 09:43 am (UTC)
you need something like $e->print_metadata(); in the entry function. do you have that? if so, you might have two definitions of Entry::print_metadata() in your layer(s).
(Reply) (Parent) (Thread) (Expand)