- Mood icon aligned left or right of the currents, or keep it inline with the mood text.
- Control which metadata is displayed, and their order.
- Link the tags label to the poster's Visible Tags Page, Edit Entry's Tags, or to the Tags Management Page.
- Replace metadata labels with pictures.
- Take off links on location, groups and music.
version history:
2.0 added inline moodpic, delinkifying music, some code cleanup
1.8 bug fixed (alt and title text of image-labels broken when label text included single apostrophes)
1.7 added custom groups functionality
1.6 added table cell width (prevents moodicon from disappearing with max-width: 100%; CSS)
1.5 bug fixed (broken tag label links)
1.4 bug fixed (mood icon showed even when mood was supposed to be hidden)
1.3 general code cleanup (minimize lines of codes and number of variables)
1.2 added left/right alignment
1.1 added metadata label pictures
1.0 basic functionality
Step 1
You need to have created a theme layer and a style before you can follow this tutorial.
if you already have a theme layer, and also already have a
function Entry::print_metadata() in it, delete it from your layer before continuing with this tutorial.Step 2
Put these set statements after the layerinfo in your theme layer as well, or use the Customizations Wizard to set the label texts:
set text_meta_mood = "Current Mood:";
set text_meta_music = "Current Music:";
set text_meta_location = "Current Location:";The Tags label can only be set in the theme layer:set text_tags = "Tags:";Step 3
Copy the following function into your theme layer. Adjust the text in red to your wishes.
set tags_aware = true;
function Entry::print_metadata()
{
# ---------------------------------------------------- CUSTOMIZATION ---------------------------------------------------- #
var string tags_sep = ", "; # text for tags separator, ", " for "tag, tag, tag"
var string show_tags_link = "none"; # set to "edit" if you want the tags label to act as an 'edit tags' link
# set to "page" if you want the tags label to link to the poster's tag page
# set to "manage" to link to the Tags Management page
# set to "none" to delinkify the tags label completely
var bool show_loc_link = false; # set to true to display the Google Map link
var bool show_groups_link = false; # set to true to display the custom friends group link
var bool show_music_link = true; # set to false to hide the last.fm link to the artist/song pages
var bool print_table = true; # set to false to display the mood icon inline with the mood text (default FS style)
var string alignment = "left"; # set the side of the mood icon (left or right of the currents) - only if printed in table
# set the order in which you want mood, music, location, tags, security and custom friends group to appear
# any metadata you want to hide journalwide, delete from this list
var string[] metaorder = ["mood", "music", "tags", "location", "groups"];
# optional:
# put in the URLs to the pics you want to use instead of the currents' text labels
# if you leave it blank, the text label will be used instead
var string{} metapics = { "mood" => "IMAGE URL",
"music" => "IMAGE URL",
"location" => "IMAGE URL",
"tags" => "IMAGE URL",
"groups" => "IMAGE URL" };
# ---------------------------------------------------- CUSTOMIZATION END ---------------------------------------------------- #
var string currents = """<div class="currents">"""; # here all metadata will be added to print currents container
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)) {
# display mood and moodicon?
var bool display_mood = false;
foreach var string moodtest ($metaorder) {
if ($moodtest == "mood") { $display_mood = true; }
}
# table and mood icon
if (defined $.mood_icon and $display_mood and $print_table) {
$currents = ($alignment == "left") ?
$currents + """<table border="0"><tr><td width="$.mood_icon.width"><img src="$.mood_icon.url" width="$.mood_icon.width" height="$.mood_icon.height" alt="$.metadata{"mood"}" title="$.metadata{"mood"}" /></td><td>""" :
$currents + """<table border="0"><tr><td>""";
}
# step through metadata in the order the user wants
foreach var string k ($metaorder) {
var string text; # the actual value of the metadata
var string label; # the label of the metadata as set in the wizard or set-statements
# handling tags metadata
if ($k == "tags" and (size $.tags > 0) and $*tags_aware) {
# label as image or text
$label = clean_url($metapics{$k}) != "" ? """<img src="$metapics{$k}" title="$*text_tags" alt="$*text_tags" border=0>""" : $*text_tags;
# optional linkage around tags label
if ($show_tags_link == "edit" and $edit_tags.url != "") { # Edit Tags Page link
$label = """<a href="$edit_tags.url">""" + $label + """</a>""";
}
elseif ($show_tags_link == "page") { # Visible Tags Page link
$label = """<a href=" """ + $.journal->base_url() + """/tag/ ">""" + $label + """</a>""";
}
elseif ($show_tags_link == "manage" and viewer_is_owner()) { # Tags Management Page link
$label = """<a href=" """ + $.journal->tag_manage_url() + """ ">""" + $label + """</a>""";
}
# build tag list
var bool addsep = false;
foreach var Tag t ($.tags) {
if ($addsep) {
$text = $text + $tags_sep + """<a rel="tag" href="$t.url">$t.name</a>""";
}
else {
$text = $text + """<a rel="tag" href="$t.url">$t.name</a>""";
$addsep = true;
}
}
} #end tags
# handling all other metadata
elseif ($k != "tags" and $k != "" and $.metadata{$k} != "") {
# metadata value
$text = $.metadata{$k};
# label as image or text
$label = clean_url($metapics{$k}) != "" ? "<img src=\"$metapics{$k}\" title=\"" + lang_metadata_title($k) + "\" alt=\"" + lang_metadata_title($k) + "\" border=0>" : lang_metadata_title($k);
# strip location/music/groups link
if ((not ($show_loc_link) and ($k == "location"))
or (not ($show_music_link) and ($k == "music"))
or (not ($show_groups_link) and ($k == "groups"))) {
$text = striphtml($text);
}
# inline mood image
if (not ($print_table) and $k == "mood" and defined $.mood_icon) {
$text = """<img src="$.mood_icon.url" width="$.mood_icon.width" height="$.mood_icon.height" alt="$.metadata{"mood"}" title="$.metadata{"mood"}" align="middle" />""" + $text;
}
} #end metadata
# skipping empty metadata
else { continue; }
# assemble the individual currents
$currents = $currents + """<div class="current$k"><strong>$label</strong> <span class="text">$text</span></div>""";
} # end foreach
# table and mood icon
if ($display_mood and defined $.mood_icon and $print_table) {
$currents = ($alignment == "left") ?
$currents + """</td></tr></table>""" :
$currents + """</td><td width="$.mood_icon.width"><img src="$.mood_icon.url" width="$.mood_icon.width" height="$.mood_icon.height" alt="$.metadata{"mood"}" title="$.metadata{"mood"}" /></td></tr></table>""";
}
# close currents container and print
println $currents + """</div>""";
}
}Step 4 (optional)
in case you want your metadata to be displayed aligned to the right, you also need to add the following CSS (either to
Page::print_custom_head(), in the Customizations Wizard or in your external stylesheet):.currents {
text-align: right;
width: 100%;
}
.currents table {
position: relative;
right: 0px;
width: 100%;
}
