no sticky, hot, messy, awful blood! ([info]airings) wrote in [info]mintyapple,

Metadata tutorial

Okay so apparently my metadata post was deleted, anyway here it is again:

How to get this for your journal:


You need a paid account, S2, Flexible Squares but works for other themes too, usage of layers.
I didn't create the code, all credit goes to [info]kunzite1 and [info]kentucka, I just edited it.


1. You must have a theme layer where you can put the code. If you're already using a theme layer, nevermind this step. If you're not using a theme layer, create one here.

2. Okay, you know the layerinfo at the top of your layer right? Mine says this:

layerinfo "type" = "theme";
layerinfo name = "LayerName";
set tags_aware = true; # this is needed to keep S2 from meshing the tags simply after the entry
set text_tags = "Tags:";


Copy and paste the parts starting from "set tags_aware".

3. If you have a themelayer it might be possible that you've edited it and put other chunks of code in there. If you have, find this code:
function Entry::print_metadata()
and delete it. If you haven't edited your theme layer at all, ignore this step.

4. Copy this in your theme layer. Doesn't matter where, as long as it's after the layerinfo.


function Entry::print_metadata() {
var string tags_header = "<img src=http://img.photobucket.com/albums/v510/mienkjen/note2.gif>"; # 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 = """<img src=http://img.photobucket.com/albums/v510/mienkjen/heart.gif>""";
}
elseif ($k == "music") { # if music, set text to music property
$text = """<img src=http://img.photobucket.com/albums/v510/mienkjen/music.gif>""";
} elseif ($k == "location") { # if location, set text to loc variable
$text = """<img src=http://img.photobucket.com/albums/v510/mienkjen/house.gif>""";
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";
}
}



5. Compile.
Please save the images to your own server!


Hope it's helpful, once again I didn't create the code, no need to credit. If you have any questions, feel free to ask! I might not be able to answer them because I'm nowhere near an expert on layers and such. If I can't answer your question, try [info]s2flexisquares.
Tags: coding: livejournal

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

  • 68 comments
Previous
← Ctrl← Alt
  • 1
  • 2
Next
Ctrl →Alt →

[info]caffrey

August 1 2007, 18:58:53 UTC 4 years ago

SWEETNESS.

Thank you! :D

[info]ihavethatshirt

August 1 2007, 18:59:06 UTC 4 years ago

Thank you so much! I've tried every code I could find to get the same effect, and finally, this one worked! Even if you didn't make it, thanks for bringing it here!

[info]tunaeverynight

August 1 2007, 19:52:15 UTC 4 years ago

AHH THANK YOU! This helped so much, I love you!

[info]dorkamatronic

August 1 2007, 20:09:25 UTC 4 years ago

That is really useful. THANK YOU.

[info]isaymeow

August 1 2007, 22:01:33 UTC 4 years ago

*mod comment

Yours wasn't the only one deleted. I contacted LJ about several entries gone missing. There is a bit of a time gap between some dates which bothers me. I noticed One of my older posts made is gone (CSS related Widgets part two) when I was updating the tags. It's like LJ ate them. I have no idea what happened and neither do they ~_~;;;;;;

I've had this happen in an icon challenge I mod about two months ago. there's a section where it goes from challenge 12 to challenge 17 with various posts in between missing x.X

[info]airings

August 2 2007, 09:53:51 UTC 4 years ago

Re: *mod comment

That is so weird! And annoying D:
I'm glad I know what happened to the post now.

[info]penguinsane

August 1 2007, 23:20:44 UTC 4 years ago

I love it!

Now If I could find this for Smooth Sailing... XD

[info]ethersol

August 2 2007, 03:20:30 UTC 4 years ago

I wish I was really good at html and all of this layers stuff.o.o Coz then I could follow this >_> Is this the only way of going about it? Or is there a more simple way? lol

[info]aurelia

August 2 2007, 05:32:22 UTC 4 years ago

Seriously, I'd never touched layers til I used this code. The code looks scary.

This is how I did it and I was on the same boat.

1.http://www.livejournal.com/manage

2.http://www.livejournal.com/customize/index.bml?authas=shadowed_howl

3. Click on the 'advanced' tab.

4.Under advanced options</u> choose Your Layers

4.Then to Create layout-specific layer</a>

5. On the 1st(type) select theme.

6.The second dropdown (layout). Either flexible squares or smooth sailing, I don't know if it works on others.

7. After you've done that click create.

8. Click edit on either the what you named it or the number. (I couldn't be bothered naming mine.)

9. Once you're in edit just copy/paste the above codes after you've changed the url's etc, hit save and compile (top of the page). Look down the bottom if there's no errors and exit.

10. Go back to the customize page and under the look and feel tab.

11. Under theme select either the number or the name of your theme, hit save changes and you're done. :)

[info]airings

4 years ago

[info]aurelia

4 years ago

[info]aurelia

4 years ago

[info]aurelia

4 years ago

[info]lizzy_maxia

August 2 2007, 12:34:12 UTC 4 years ago

Goes to my memories, will try later, thanks!

[info]worship_elle

August 2 2007, 14:59:03 UTC 4 years ago

That looks very usefull THANKS!!

[info]silverlining_xx

August 4 2007, 03:02:58 UTC 4 years ago

thank you! ♥

[info]facepace

August 5 2007, 06:35:26 UTC 4 years ago

OMG THANK YOU.
i've been trying to figure this out for the longest. 8D;
will attempt to do after i take a nap. XD

[info]oatmeal_cookie

August 5 2007, 14:55:54 UTC 4 years ago

THANK YOU. :D

[info]kentucka

August 6 2007, 10:30:27 UTC 4 years ago

the code you posted is completely [info]kunzite1's, no need to credit me for it :) my version was using that code as a basis, and is now here and allows for a bit more customization.

[info]riverfleur

August 6 2007, 17:22:18 UTC 4 years ago

Wow, that is pretty amazing. Usually I can't figure out how to do stuff like this... but this was extremely helpful. Thanks!

[info]ebonystar

August 7 2007, 15:26:32 UTC 4 years ago

Ace! Love it - I finally have an LJ I'm proud of...

yay!
and thank you!

[info]celebrity___x3

August 7 2007, 16:14:30 UTC 4 years ago

That was very helpful, thank you! I've never used layers before and you made it easy to understand :)

[info]asphyxi

August 8 2007, 06:17:29 UTC 4 years ago

took and in use. :)

[info]soapboxfelonies

September 2 2007, 21:13:50 UTC 4 years ago

meming! thank you, this is very helpful.

[info]schmiss

September 13 2007, 16:06:55 UTC 4 years ago

Sweeeeeeeeeeeeeeeeet. Thanks!

[info]mousoucarnival

September 18 2007, 19:43:27 UTC 4 years ago


Thank you thank you thank you!! :D ♥

[info]ms_vogue

September 24 2007, 16:08:44 UTC 4 years ago

Dammit! You need a paid account!
I am soooooo getting one!!
btw.. thanks for it! ++ for when i get one!

[info]potthead

September 29 2007, 23:14:45 UTC 4 years ago

I was using your code for my Flexible Squares layout, but suddenly it's not really working, so I was wondering if you knew what was up? I'm customizing my Flexible Squares layout with the CSS section under 'custom options'. I have a separate 'theme' called 'mood' that has your coding in it for the metadata, but whenever I use it now, all my CSS for the layout seems to be ignored, so I get your metadata coding all over the default 'Blue Gray' Flexible Squares layout. Would you happen to know if I'm doing something wrong? ^^;;

[info]airings

September 30 2007, 09:38:14 UTC 4 years ago

I wish I could help, but I really don't know much about layers and stuff. I just copy codes :p
I suggest you ask this at [info]s2flexisquares, the people there are great!

[info]potthead

4 years ago

[info]_omnivore_

October 3 2007, 23:16:07 UTC 4 years ago

Thank the gods you posted this again! I was panicking when I saw that the link in my memories didn't work. :D

[info]seroquels

October 13 2007, 04:58:47 UTC 4 years ago

Is there anyway to do this modification while using a CSS Style sheet?
When I add the theme layer it takes away everything that's in my CSS box in the Customization Wizard.

[info]aurelia

September 3 2008, 09:23:25 UTC 3 years ago

Do you still need help? Took me awhile to find everything since LJ changed their set ups.

[info]seroquels

3 years ago

[info]mosquetera

October 16 2007, 00:41:47 UTC 4 years ago

Genius!
Previous
← Ctrl← Alt
  • 1
  • 2
Next
Ctrl →Alt →
Create an Account
Forgot your login or password?
Facebook Twitter More login options
English • Español • Deutsch • Русский…