(no subject)

Mar 16, 2009 16:05

I've had a couple of people ask me how I managed the code that solved my previous problems, so I'm posting it for everyone to have. This code will let you move the mood icon to the left of all metadata, reorder your metadata in any order you want, and also, to unlink your location.


black = leave this alone
red = change this code to fit what you want.
blue = optional change
## = Comments. Make sure you read them; there may be info here to help you modify the code.

function Entry::print_metadata() {

## If there is metadata (mood, music, location) or tags to print, and we're not in the guestbook, print stuff.
if (((size $.metadata>0) or ((size $.tags>0)and($*layout_position_entrytags=="metadata"))) and ($.itemid!=int($*layout_guestbook_entryid))) {

## Initialise the variables to print the metadata. Nothing prints here.
var string metaopen = "
";
var string tags = "";
var string location = "";
var string mood = "";
var string music = "";
var string groups = "";
var string moodicon = "";
var string metaclose = "";
var bool moodiconaftertext = false; ## set to true to place mood icon after text
var string separator = ": "; ## set separator to any symbol

## Construct the tags if there are any, and if tags are set to print with metadata
if ((size $.tags>0)and($*layout_position_entrytags=="metadata")) {
var string text = $*text_meta_tags;
$text = """TAGS IMG URL" class="pic" />
tags → """;
$tags = "$text $.tags[0].name";
foreach var int i (1 .. (size $.tags - 1)) {
$tags = $tags + ", $.tags[$i].name";
}
$tags = $tags + "
";
}

## Construct the location. To have location appear as a link, delete the blue text below.
if ($.metadata{"location"}!="") {
var string text = $*text_meta_location;
$text = """LOCATION IMG URL" class="pic" />
location → """;
$location = "$text"+striphtml($.metadata{"location"})+"
";
}

## Construct the mood
$moodicon = $.mood_icon + "";

if ($.metadata{"mood"}!="") {
var string text = $*text_meta_mood;
$text = """MOOD IMG URL" class="pic" />
mood → """;
$mood = "$text";
if (defined $.mood_icon and $moodiconaftertext) {
$mood = $mood + $.metadata{"mood"}+" ";
} elseif (defined $.mood_icon and not $moodiconaftertext) {
$mood = $mood + " " + $.metadata{"mood"};
} else { $mood = $mood + $.metadata{"mood"};
}
$mood = $mood + "
";
}

## Construct the music
if ($.metadata{"music"}!="") {
var string text = $*text_meta_music;
$text = """MUSIC IMG URL" class="pic" />
music → """;
$music = "$text"+$.metadata{"music"}+"
";
}

## Construct the groups
if ($.metadata{"groups"}!="") {
var string text = $*text_meta_groups;
$text = """GROUPS IMG URL" class="pic" />
groups → """;
$groups = "$text"+$.metadata{"groups"}+"
";
}

## Print the elements in the specificed order. You can move any of these around EXCEPT $metaopen, $moodicon, and $metaclose.
print $metaopen + $moodicon + $mood + $location + $music + $tags + $groups + $metaclose;
}
}

metadata, mood icon, tutorial

Previous post Next post
Up