Basic Coding Essentials

Jan 11, 2010 19:53

I'm having problems with the following, which have been solved/explained for other people in the past, so I think that, rather than having madly messed up the code (though I may have managed that as well :S), I'm mostly just missing some really basic yet essential piece of coding somewhere.

[Solved by me] 1. Adding an image when posts are public, solved here.
[Solved myself] 2. Getting rid of "X comments, Post a new comment" text on comments pages, (potentially) solved here.
[Solved myself] 3. Editing links in the header strip, tutorial here.

4. Inexplicable (to me, at any rate...) gap between header link strip and entry, when viewing entry with comments. I've tried a few of the suggestions given for this in the past, to no avail, so fear that it is again a case of my missing something vital.

As my theme layer is full of compiling errors, my code is here:
layerinfo "type" = "theme";
layerinfo "name" = "Japan";

function TagsPage::print_body
{
#### TAG CLOUD CODE ####

###### Configuration ######

var int tag_category = 8; # The number can be changed if you want more or fewer categories.
var int basefontsize = 80; # size of the first tag category in percent of the default font size of the page.
var int increment = 50; # The difference in size between tag categories.
var string subject = "Tags"; # Title of the tag page.

###### End Configuration ######

var Page p = get_page();
var string list = "";
var int max_use_count = 0 ;
var int min_use_count ;
var int x ;

if (size $p->visible_tag_list() > 0)
{

# Define a maximum and minimum number of uses of the tags:
var TagDetail[] visible_tag_list = $p->visible_tag_list();
if($visible_tag_list)
{
$min_use_count = $visible_tag_list[0].use_count;
foreach var TagDetail td ($p->visible_tag_list())
{
if ($td.use_count > $max_use_count)
{
$max_use_count = $td.use_count;
}
elseif ($td.use_count < $min_use_count)
{
$min_use_count = $td.use_count;
}

}
}

# Avoid a division by zero
if ($max_use_count == $min_use_count)
{
$max_use_count = $max_use_count + 1;
}

# Put the tags into categories according to the number of times they're used,
# then use it to determine the size of the tag:
foreach var TagDetail td ($p->visible_tag_list())
{
# Create different categories according to the number of uses of the tag
$x = (($td.use_count - $min_use_count) * $tag_category / ($max_use_count - $min_use_count));
if ($x == $tag_category) { $x = $tag_category - 1; }

# Convert those categories into sizes
$x = ($x * $increment) + $basefontsize;
$list = $list + """$td.name """;
}

# Enclose the entire list in a paragraph tag.
$list = """

""" + $list + """

""";

}

#### END TAG CLOUD CODE ####

#### Print the tag cloud in an entry-like post ####

function Page::lay_print_header()
"Prints header"
{
var Page page = get_page();
var string title = $this->title();

# by default, LJ can print the following links in the header navigation:
#
# userinfo ... the profile page
# recent ..... the recent entries page
# friends .... the friends page (no filter)
# archive .... the calendar (current year page)
# tags ....... the visible tags page
#
# the skiplinks are not available in the header by default, but were added by this tutorial:
#
# forward .... the 'skip a number of entries forward' link (younger entries)
# back ....... the 'skip a number of entries back' link (older entries)

# specify the URL of any additional links you'd like to show up in the header navigation
# of LJ default links that you'd like to override (except skiplinks)
# (e.g. to link to a friends filter rather than the normal friends page)
# if you don't want to change anything, leave empty curly braces {};
var string{} links = {};

# specify the order in which the links are supposed to show up (use "|" to add linebreaks):
var string[] order = ["recent", "friends", "tags", "userinfo"];

# specify the link text: can be text or an image tag ( ... please use single quotes around the URL)
# or leave blank to use the text set in the Customization Wizard for the default links and skiplinks
# (custom links will show as "Unknown View" if left blank)
var string{} text = { "userinfo" => "user info",
"recent" => "recent entries",
"friends" => "friends",
"tags" => "tags",
};

# link current view: set wether or not you want the current view
# (e.g. the navigation item saying Friends while you're on your friends page)
# to be a link (set it to true) or not (set it to false).
var bool link_current_view = false;

# display website: set whether or not to print the website specified in the Customization Wizard
# (if set to true, website will always display as the very first link)
var bool display_website = false;

# --- do not edit beyond this point --- #

print """

""";
}

function print_entry(Page p, Entry e, Color bgcolor, Color fgcolor)
{
"""""";
$e->print_linkbar();

# Userpic

var string userpic = "";
if ($*show_entry_userpic)
{
if ($p.view == "friends" or $p.view == "entry" or $p.view == "reply")
{
if (defined $e.userpic)
{
$userpic = $userpic + """$e.poster.name if ($e.poster.username != $e.journal.username)
{
$userpic = $userpic + " in $e.journal.name";
}
$userpic = $userpic + "\">";
}
}
elseif ($p.journal_type == "C" and $p.view == "recent")
{
if (defined $e.userpic)
{
$userpic = $userpic + """$e.poster.name""";
}
}
else
{
if (defined $e.userpic)
{
$userpic = $userpic + """
$e.poster.name
""";
}
}
}
print """

""";
if (($p.view == "recent" and $p.journal_type != "C" ) or $p.view == "day")
{
print """$userpic""";
}
else
{
if ($p.view == "recent" and $p.journal_type == "C" )
{
"""
""";
}
else
{
"""
""";
}
print """$userpic""";

# Poster

if ($p.view == "friends" or $p.view == "entry" or $p.view == "reply")
{
var UserLite linkto;
$linkto = $e.poster;
#print "$e.poster.username";
"""
base_url() + "\">";
"$linkto.username
";
}
elseif ($p.journal_type == "C" and $p.view == "recent")
{
var UserLite linkto;
$linkto = $e.poster;
#print "$e.poster.username";
"""
base_url() + "\">";
"$linkto.username
";
}
if (($p.view == "friends" or $p.view == "entry" or $p.view == "reply") and $e.poster.username != $e.journal.username)
{
var UserLite linkto;
$linkto = $e.journal;
"""
[base_url() + "\">";
"$linkto.username
]";
}
if ($p.view == "recent" and $p.journal_type == "C")
{
print "
";
}
if ($p.view != "recent" and $p.view != "day")
{
print """
""";
}
}

# Date, time, subject

var string time = "";
$time = $time + """ @ """;
$time = $time + $e.time->time_format("short");
var string date = "";
$date = $date + $e.time->date_format("long_day");
"""
""";
print $e.time->date_format("%%dd%% %%month%% %%yyyy%%");
"$time
";
"""
""";
if ($e.security != "")
{
$e.security_icon->print();
}
else
{
print """http://img.photobucket.com/albums/v334/Punkheid/pencil.png" alt="public" title="public">""";
}
if ($p.view != "entry") {
print $e->formatted_subject({"class"=>"subj-link"});"  ";
}
else { print "$e.subject  "; }
"""


""";

"""

""";

$e->print_text();
print "
";

# Currents

var string currents ="";
$e->print_metadata();

# Comments

"""
 

""";
if ($p.view != "entry" or $p.view != "reply")
{
$e.comments->print();
}
elseif ($e.comments.enabled)
{
$e.comments->print_postlink();
}
else
{
" ";
}
"""





 
""";
}

function EntryPage::print_body()
{
$this->print_entry($.entry);

if ($.entry->viewer_sees_ebox()) {
"""
""";
$.entry->print_ebox();
"""



""";
}

if ($.multiform_on and $.entry.comments.enabled and $.comment_pages.total_subitems > 0)
{
$this->print_multiform_start();
}

var string comments_count = string($.entry.comments.count);
if ($.viewing_thread) {
var string toplink = (($.comment_pages.total > 1) ? ($.comment_pages->url_of($.comment_pages.current)) : $.entry.permalink_url) + "#comments";
$comments_count = """"""+ get_plural_phrase($.entry.comments.count, "text_read_all_comments") +"""""";
} else {
$comments_count = get_plural_phrase($.entry.comments.count, "text_read_comments");
}
if ($.entry.comments.count > 0) {
$comments_count = """$comments_count - """;
} else {
$comments_count = "";
}

if ($.entry.comments.enabled)
{
"""


""";
$.comment_pages->print();

$this->print_reply_container({"target" => "topcomment"});
$this->print_comments($.comments);
"""
""";
}

if ($this.multiform_on and $.entry.comments.enabled and $.comment_pages.total_subitems > 0)
{
"""
""";
$this->print_multiform_actionline();
$this->print_multiform_end();
"""

( $comments_countPost a new comment )""";
$.comment_pages->print();
"""


""";
}
"""


""";

}

And my CSS, in case that is causing some clashes:

/*-------------------------------------------------------------------
S2 Flexible Squares Stylesheet
by exitclosed.livejournal.com

Change anything you like, but you MUST credit me with a LINK BACK.

Please do not remove this section
------------------------------------------------------------------*/

/*-------------------------------------------------------------------
Basics
-------------------------------------------------------------------*/
body {
background-color: #7db48a;
text-align: justify;
color: #4b7567;
font-family: Arial;
font-size: 11px;
margin: 15px 0px 15px 0px;
}

a, a:link, a:visited {
cursor: default;
color: #FFFFFF;
text-decoration: none;
}
a:hover {
cursor: default;
color: #86bb53;
text-decoration: none;
}

p, blockquote {
font-size: 9px;
padding: 20px;

}

code, kbd, pre, tt {
font-size: 9px;
padding: 20px;
}

/*-------------------------------------------------------------------
General page alignment and width
-------------------------------------------------------------------*/
#content {
width: 510px;
margin-left: auto;
margin-right: auto;
background-color: transparent;
border: 0px;
padding: 0px;
}

#maincontent {
float: right;
width: 100%;
margin: -95px 0px 0px 0px;
background-color: #FFFFFF;
color: #4b7567;
text-align: justify;
}

#sidebar {
display: none;
}

/*-------------------------------------------------------------------
Header and header image
-------------------------------------------------------------------*/
#header {
width: 510px;
margin: 0px 0px 0px 0px;
background-color: #7db48a;
text-align: center;
font-family: Trebauchet MS;
font-size: 30px;
font-weight: none;
letter-spacing: -1px;
color: #FFFFFF;
text-transform: lowercase;
}

div#header a, div#header a:link, div#header a:visited{
cursor: default;
color: #FFFFFF;
letter-spacing: -1px;
text-transform: lowercase;
text-decoration: none;
}

div#header a:hover{
cursor: default;
color: #86bb53;
letter-spacing: -1px;
text-transform: lowercase;
text-decoration: none;
}

.title {
visibility: hidden
}

.subtitle{
visibility: hidden
}

.headerimage {
position: relative;
width: 490px;
height: 348px;
margin-left: auto;
margin-right: auto;
background-image: url('http://img.photobucket.com/albums/v334/Punkheid/73705239.jpg');
background-repeat: no-repeat;
border: 10px #FFFFFF solid;
}

/*-------------------------------------------------------------------
Header links section
-------------------------------------------------------------------*/
ul.navheader {
padding: 15px;
margin: 0px;
}

ul.navheader li {
display: inline;
padding: 0 3px 0 3px;
}

/*-------------------------------------------------------------------
Entry stuff
-------------------------------------------------------------------*/
.entry {
margin: 0px 0px 0px 0px;
padding-left: 40px;
padding-right: 40px;
padding-bottom: 20px;
padding-top: 20px;
background-color: #FFFFFF;
font-weight: none;
text-align: justify;
font-size: 11px;
font-family: Arial;
font-color: #4b7567;
}

.userpic {
position: relative;
float: left;
text-align: center;
margin: 10px 10px 10px 10px;
padding: 0px;
background-color: transparent !important;
color: #7db48a !important;
}

.userpic img {
background-color: #FFFFFF;
border: 0px solid #C8D7DA;
padding: 5px;
}

.date {
text-align: left;
line-height: 100%;
color: #1d3525;
font-family: Trebauchet MS;
font-size: 10px;
margin-top: 5px;
}
.subject {
padding: 0px;
text-align: left;
color: #1d3525;
font-family: Trebauchet MS;
font-size: 20px;
text-transform: lowercase;
line-height: 18px;
}

.skiplinks { text-align: center;
text-transform: lowercase;
padding: 5px;
}

a, a:link, a:visited {
cursor: default;
color: #1d3525;
text-decoration: none;
}

.subject a:hover {
cursor: default;
color: #1d3525;
text-decoration: none;
}

.datesubject {
background-color: #FFFFFF;
padding: 5px;
border-bottom: 1px solid #E2E2E2;
}

.entry ul li {
padding-left: 5px;
margin-left: 15px;
}

.entry ol li {
padding-left: 5px;
margin-left: 15px;
}

.ljuser img
{
/* fallback code for older browsers */
width: 0;
height: 0;
padding: 16px 0 0 16px;
/* for some reason IE doesn't understand
background shortcuts for this one */
background-image: url('http://img.photobucket.com/albums/v334/Punkheid/user_green.png');
background-repeat: no-repeat;
background-position: left center;
}

.ljuser img[src="http://p-stat.livejournal.com/img/userinfo.gif"]
{ background-image: url('http://img.photobucket.com/albums/v334/Punkheid/user_green.png'); }

.ljuser img[src="http://p-stat.livejournal.com/img/community.gif"]
{ background-image: url('http://img.photobucket.com/albums/v334/Punkheid/group.png'); }
}

.subject img[src="http://l-stat.livejournal.com/img/icon_protected.gif"]{
width: 0; height: 0; padding: 0 16px 16px 0; background: url(http://img.photobucket.com/albums/v334/Punkheid/lock.png); }

.subject img[src="http://l-stat.livejournal.com/img/icon_private.gif"]{
width: 0; height: 0; padding: 0 16px 16px 0; background: url(http://img.photobucket.com/albums/v334/Punkheid/key.png); }

.subject img[src="http://l-stat.livejournal.com/img/icon_groups.gif"]{
width: 0; height: 0; padding: 0 16px 16px 0; background: url(http://img.photobucket.com/albums/v334/Punkheid/lock.png); }

/*-------------------------------------------------------------------
Entry Stuff - Current Mood, Music and Location
-------------------------------------------------------------------*/

.currents strong{
font-weight:normal;
}

.currentgroups { display: none; }

/*-------------------------------------------------------------------
Entry Stuff - Comments
-------------------------------------------------------------------*/
.comments {
font-family: Arial;
font-size: 11px;
text-align: right;
padding: 10px 10px 10px 10px;
position: relative;
}

div.comments a, div.comments a:link, div.comments a:visited{
cursor: default;
color: #86bb53;
text-decoration: none;
}

div.comments a:hover {
cursor: default;
color: #86bb53;
text-decoration: none;
}

/*-------------------------------------------------------------------
Entry Stuff - Separator
-------------------------------------------------------------------*/
/* for formatting separators between entries */

.separator{
height: 20px;
background-color: #7db48a !important;
border: 0px !important;
}

/*-------------------------------------------------------------------
Special friends page customization
-------------------------------------------------------------------*/
.userpicfriends {
position: relative;
float: left;
text-align: center;
margin: 10px 10px 10px 10px;
padding: 0px;
background-color: transparent !important;
color: #C8D7DA !important;
}

.userpicfriends img {
background-color: #FFFFFF;
border: 0px solid #C8D7DA;
padding: 5px;
}

/*-------------------------------------------------------------------
Archive Pages
-------------------------------------------------------------------*/
ul.year {
text-align: center;
padding-bottom: 40px;
}

ul.year li {
display: inline;
}

table.yeartable {
margin-left: auto;
margin-right: auto;
}

table.yeartable td.yeardate, table.yeartable td.yearday {
border: 1px solid #ABABAB;
}

table.yeartable td.yearday {
background-color: #FFFFFF;
text-align: center;
}

td.yearmonth {
border-style: none;
}

/*-------------------------------------------------------------------
Misc
-------------------------------------------------------------------*/
.clear {height: 0px;}

.entry ul li {
padding-left: 5px;
margin-left: 15px;
}

.entry ol li {
padding-left: 5px;
margin-left: 15px;
}

/*-------------------------------------------------------------------
Footer
-------------------------------------------------------------------*/
#footer {
width: 100%;
color: #FFFFFF;
font-family: Trebauchet MS;
font-size: 20px;
background-color: #7db48a;
clear: none;
text-align: center;
}

div#footer a, div#footer a:link, div#footer a:visited {
cursor: default;
color: #FFFFFF;
text-decoration: none;
}

div#footer a:hover {
cursor: default;
color: #86bb53;
text-decoration: none;
}

ul.navfooter{
padding: 5px;
margin: 0px;
}

ul.navfooter li {
display: inline;
margin-bottom: 15px;
padding: 0px 5px 0px 5px;
background: transparent;
text-align: center;
font-size: 20px;
font-family: Trebauchet MS;
text-transform: lowercase;
}

.clearfoot {
display: none;
}

/*-------------------------------------------------------------------
Misc
-------------------------------------------------------------------*/
.clear {height: 0px;}

Many apologies for this not being easily laid out! (Please let me know if you would rather that I post it all behind a cut in this entry, rather than in the textboxes - I am unsure which of these is best policy.)

Any suggestions/whacks around the head for missing the obvious would be greatly appreciated!

comments, getting started, header and footer, entries, entry security icons, paid accounts

Previous post Next post
Up