Different metadata on your pages and your friends with Flexible Squares

Apr 09, 2006 20:40

In response to this post by swishy-fresh in s2styles


This function will allow you to:
- have different lables for the meta data than the defaults
- have different lables for the meta data on your friends page than on your own entries
- remove the google maps link from the location
- rearange the order your lables are printed in

function Entry::print_metadata()
{
#if there is meta data then carry out the rest of this
if (size $.metadata)
{
#figure out which page we are on and then define the lables for the meta data accordingly
var Page this_page = get_page();
var string lable_location = "";
var string lable_mood = "";
var string lable_music = "";
if ($this_page.view == "friends")
{
#lables for meta data on your friends page
$lable_location = "text for new location here";
$lable_mood = "$*text_meta_mood";
$lable_music = "$*text_meta_music";
}else{
#lables for meta data on all pages which are not your friends page
$lable_location = "text for new location here";
$lable_mood = "$*text_meta_mood";
$lable_music = "$*text_meta_music";
}

#define variables to contain the XHTML output for each piece of metadata
var string my_location = "";
var string my_mood = "";
var string my_music = "";

#go through each item of meta data and put together the XHTML
foreach var string k ($.metadata)
{
# text is equal to LJ's lable for the meta data - eg. "mood"
var string text = $k;
# val is equal to what we typed for the mete data - eg. "happy"
var string val = $.metadata{$k};

# if this is the mood metadata then we want to add the mood icon to the value
if ($k == "mood" and defined $.mood_icon)
{
var Image i = $.mood_icon;
$val = " $val";
}
# if this is the location metadata then we want to remove the link to google maps from it
elseif ($k == "location")
{
$val = striphtml($val);
}

#define how we want each line of metadata to start and end
var string start_current = """
""";
var string end_current = "
$val
";

# create the XHTML for each peice of metadata so it contains the beginning, lable/text, value, and end of the XHTML
if ($k == "location")
{
$my_location = $my_location + $start_current + $lable_location + $end_current;
}
elseif ($k == "mood")
{
$my_mood = $my_mood + $start_current + $lable_mood + $end_current;
}
elseif ($k == "music")
{
$my_music = $my_music + $start_current + $lable_music + $end_current;
}
}
#print the beginning of the div to contain all metadata, then print the metadata, then print the end of the div
print """
""";

# these three can be traded around to be put in any order
print $my_location;
print $my_mood;
print $my_music;

print "
";
}
}

lj

Previous post Next post
Up