| unique.wonders. ( @ 2008-04-05 00:28:00 |
| Entry tags: | !tutorial, *account level: paid/perm, class: replypage, function: print_body, user: uw |
TUTORIAL: [Entries] Custom Entries on the Reply Page
Difficulty Level
Related Tutorials
Instructions
» Copy and paste the code located in the box.
» Read the code for further instructions on how to change settings and data. Instructions are in green. Settings and data you can change are in red.
» Spot the blue lines if you need to insert some related tutorials.
» Enjoy! :)
» Read the code for further instructions on how to change settings and data. Instructions are in green. Settings and data you can change are in red.
» Spot the blue lines if you need to insert some related tutorials.
» Enjoy! :)
Thanks & Credit
» Credit goes to
kunzite1 and
xtomxfallsx for writing the original version of this tutorial.
########################################
# REPLY PAGE - CUSTOM ENTRIES (V2) #
# overrides: #
# ReplyPage::print_body() #
# source: #
# component_help/1204587.html #
########################################
### Important! If you're replying to an entry, the entry on the reply page will automatically look exactly like your other entries. ###
### If you're replying to a comment, you need to set some options below to make it look like an entry. ###
#===============================================
#
# PROPERTIES PERTAINING TO ENTRIES #
#
#===============================================
### COMMENT LINKS PROPERTIES ###
set text_reply_nocomments_header = "Comments Disabled:";
set text_reply_nocomments = "Comments have been disabled for this post.";
function ReplyPage::print_body ()
{
##### START CONFIGURATION. THIS IS WHERE YOU SET YOUR OPTIONS. #####
### USERPIC OPTIONS ###
# Position of userpics: inside or outside?
var string icon_position = "outside";
# Position of userpics: right or left?
var string icon_side = "left";
# If userpics are inside, have a border: true or false?
var bool show_border = false;
### SCROLLBAR OPTIONS ###
# Implement horizontal scrollbars: true or false?
# These will make sure your layout doesn't stretch horizontally when large content is posted.
var bool show_hscroll = false;
##### END CONFIGURATION. #####
##### DO NOT EDIT ANY OF THE FOLLOWING CODE UNLESS YOU KNOW WHAT YOU'RE DOING! #####
### If comments have been disabled, say so.
if (not $.entry.comments.enabled) {
print "<h2>$*text_reply_nocomments_header</h2><p>$*text_reply_nocomments</p>";
return;
}
if ($.replyto isa Entry) {
var Entry en = $.replyto as Entry;
print_entry ( $this, $en, null Color, null Color, false );
} else {
var Page p = get_page();
var string time = $.replyto.time->time_format();
var string date = $.replyto.time->date_format("long");
var string poster = (defined $.replyto.poster) ? $.replyto.poster->as_string() : "<i>(Anonymous)</i>";
var string journal = $.replyto.journal->as_string();
var string subject = $.replyto.subject;
var string padding_pos = "";
$padding_pos = (($icon_side == "left") or ($icon_side == "right")) ? (($icon_side == "left") ? "right" : "left") : "";
var string iconborder = "";
var string icon_data = "";
### Variable for scrollbar.
var string scrolling = $show_hscroll ? "style='table-layout: fixed;'" : "";
### Build the entry header.
var string entry_header = "";
$entry_header = $entry_header + $time + " " + $date;
## Build the userpic and username if they exist/should be shown.
# Start inside userpic section.
if ($icon_position == "inside") {
if ($show_border){
$iconborder = " border: thin solid $*entry_fgcolor;";
}
$icon_data = $icon_data + """<div style="text-align: center; padding: 2px; float: $icon_side; margin-$padding_pos: 4px; margin-bottom: 4px;$iconborder">""";
if (defined $.replyto.userpic) {
$icon_data = $icon_data + """<div style="padding: 3px;"><a href="$*SITEROOT/allpics.bml?user=$.replyto.poster.username"><img border="0" src="$.replyto.userpic.url" width="$.replyto.userpic.width" height="$.replyto.userpic.height" alt="$.replyto.poster.name" title="$.replyto.poster.name" /></a></div>""";
}
$icon_data = $icon_data + """<div class="ljuser">""";
if (($.replyto.poster.username != $.replyto.journal.username) and ($p.journal_type == "C")) { $icon_data = $icon_data + """$journal<br />"""; }
$icon_data = $icon_data + """$poster</div></div>""";
}
# End userpic inside section.
elseif ($icon_position == "outside") {
# Start outside userpic section.
$icon_data = """
<td valign="top" style="padding-$padding_pos: 8px;">
<table cellspacing="0" cellpadding="0" align="center">""";
if (defined $.replyto.userpic) {
$icon_data = $icon_data + """<tr><td align="center" class="userpic"><a href="$*SITEROOT/allpics.bml?user=$.replyto.poster.username"><img border="0" src="$.replyto.userpic.url" width="$.replyto.userpic.width" height="$.replyto.userpic.height" alt="$.replyto.poster.name" title="$.replyto.poster.name" /></a></td></tr>
<tr><td><img src="$*PALIMGROOT/component/clear.gif" width="1" height="2" alt="" /></td></tr>""";
}
$icon_data = $icon_data + """<tr><td align="center" class="ljuser">""";
if (($.replyto.poster.username != $.replyto.journal.username) and ($p.journal_type == "C")) { $icon_data = $icon_data + """<div align="center" class="ljuser">$journal</div>"""; }
$icon_data = $icon_data + """$poster</td></tr></table></td>""";
# End userpic outside section.
}
## End userpic and username section.
### Print the entry header.
print_entry_header($entry_header);
### Start the table holding the rest of the entries.
"""
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="1" class="dkLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
<td class="entryHolderBg" width="100%">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>""";
## Print the userpic/username section if outside and left.
if ($icon_position == "outside" and $icon_side == "left") {
print $icon_data;
}
## Start the entry text area.
"""<td width="100%" valign="top">""";
"""
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="100%">
<table cellspacing="0" cellpadding="0" width="100%"$scrolling>
<tr>
<td width="1" class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
<td class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
<td width="1" class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td width="1" class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
<td class="entry">
""";
# Print the subject.
if ($subject !="") {
"""<div class="entryHeader">$subject</div>
<div class="entryDash"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></div>
</td>
<td width="1" class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td width="1" class="medLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
<td class="entry">""";
}
# Print the userpic/username section if inside.
if ($icon_position == "inside") {
print $icon_data;
}
# Add <div> around entry text and metadata to implement scrollbars.
if ($show_hscroll) {
"""<div style="width: 100%; overflow: auto;">""";
} else {
"""<div>""";
}
# Print the entry text.
"""<div>"""; $.replyto->print_text(); """</div>""";
## End of the entry text area.
# Close <div> around entry text and metadata.
"""</div>""";
print_content_bottom();
## Print the comments links.
"""
<table width="100%">
<tr>
<td align="left" valign="center"><div class="entryComments"><a href="$.entry.comments.read_url">$*text_reply_back</a></div></td>
""";
### Close the comments area.
"""
</tr>
</table>
""";
### Prints icon now if outside right.
if ($icon_position == "outside" and $icon_side == "right") {
print $icon_data;
}
### End the entry component and put a spacer after it so that entry components are separated.
"""
</tr>
</table>""";
### Round Reply Page ###
### Replace these lines with the code from the second box. ###
var int cs;
$cs = 5;
if ($icon_position == "inside") { $cs = 4; }
"""</td>
<td width="1" class="dkLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
</tr><tr>
<td width="1" colspan="$cs" class="dkLine"><img src="$*PALIMGROOT/component/clear.gif" width="1" height="1" alt="" /></td>
</tr>
</table>""";
""" <div><img src="$*PALIMGROOT/component/clear.gif" width="3" height="3" alt="" /></div> """;
### Round Reply Page ###
### End of replacement. ###
}
### Round Reply Page ###
### Insert all the variables from the third box here. ###
### Round Reply Page ###
### Replace this line with print $box_open; ###
print_system_box_top();
"<h2>Reply</h2>";
$.form->print();
### Round Reply Page ###
### Replace this line with print $box_close; ###
print_system_box_bottom();
}