Making Blog Title Link to Main Page

Nov 05, 2007 19:41

I am customizing my blog, and for the most part have things the way I want them.  The final couple of things I want to accomplish are as follows:

I want my blog title ToaCx4 which shows on every page to link to the blog's main page so that you can easily return to the front page no matter where you are.

I also want my banner/header to do the same ( Read more... )

Leave a comment

av8rmike November 6 2007, 14:31:58 UTC

function print_banner(Page p) {
container_open("banner");
print safe """ $p.global_title
""";
print safe """$p.global_subtitle
""";
container_close();
}

function Page::print_entry(Entry e) {
"
\n";

var bool showtime = $*opt_showtime;
var bool showdate = not $*opt_datehead;
var bool showposter = false;
var bool showuserpic = $*opt_userpic_main;
if ($.view == "friends") { $showtime = true; $showposter = true; $showuserpic = $*opt_userpic_friends; }
if ($.view == "day") { $showdate = false; }
if ($.view == "entry" or $.view == "reply") { $showdate = true; }
if ($.view == "entry") { $showuserpic = $*opt_userpic_entrypage; }
if (not $e.poster->equals($e.journal)) { $showposter = true; }

if (($showuserpic and defined $e.userpic) or $showposter) {
"
";
if ($showuserpic and defined $e.userpic) { "$e.userpic"; }
if (($showuserpic and defined $e.userpic) and $showposter) { "
"; }
if ($showposter) { print safe "
"+lang_posted_by($e.poster, $e.journal, $this)+"
"; }
"";
}

"";
if (defined $e.security_icon) {
print "$e.security_icon ";
}
""" $e.subject
\n";
"
\n";

"
\n";
$e->print_metadata();
$e->print_text();
"\n";

var string sep = "|";

"
";
if ($showdate or $showtime) {
print lang_posted_date_and_time($e, $e.time, $showdate, $showtime)+" $sep ";
}
" $*text_permalink";

if ($e.comments.show_postlink) { " $sep "; $e.comments->print_postlink(); }
if ($e.comments.show_readlink) { " $sep "; $e.comments->print_readlink(); }

$e->print_linkbar();
"
";

"\n";
"\n";
}

Reply

jaceman November 6 2007, 15:16:52 UTC
Pilot Mike,

I appreciate the reply... pretty quick too.

When I paste the code above into my current custom theme layer and compile, I get the following error...

S2 Compiler Output at Tue Nov 6 15:14:51 2007
Error compiling layer:

Compile error: : Unexpected end of file. Unclosed string literal?
S2::NodeTerm, S2/NodeTerm.pm, 318
S2::NodeIncExpr, S2/NodeIncExpr.pm, 41
S2::NodeTypeCastOp, S2/NodeTypeCastOp.pm, 29
S2::NodeInstanceOf, S2/NodeInstanceOf.pm, 29
S2::NodeUnaryExpr, S2/NodeUnaryExpr.pm, 40
S2::NodeProduct, S2/NodeProduct.pm, 28
S2::NodeSum, S2/NodeSum.pm, 31
S2::NodeRelExpr, S2/NodeRelExpr.pm, 29
S2::NodeEqExpr, S2/NodeEqExpr.pm, 29
S2::NodeLogAndExpr, S2/NodeLogAndExpr.pm, 29
S2::NodeLogOrExpr, S2/NodeLogOrExpr.pm, 29
S2::NodeRange, S2/NodeRange.pm, 29
S2::NodeCondExpr, S2/NodeCondExpr.pm, 29
S2::NodeAssignExpr, S2/NodeAssignExpr.pm, 29
S2::NodeExpr, S2/NodeExpr.pm, 29
S2::NodePrintStmt, S2/NodePrintStmt.pm, 48
S2::NodeStmt, S2/NodeStmt.pm, 36
S2::NodeStmtBlock, S2/NodeStmtBlock.pm, 42
S2::NodeFunction, S2/NodeFunction.pm, 104
S2::Layer, S2/Layer.pm, 58
S2::Compiler, S2/Compiler.pm, 27

Reply

av8rmike November 6 2007, 16:36:57 UTC
Oops. This line:
""" $e.subject
\n";
should have two more quotes in it:
""" $e.subject
\n""";

Reply

jaceman November 6 2007, 16:52:00 UTC
Your help is most appreciated.

Now we get this:

S2 Compiler Output at Tue Nov 6 16:51:24 2007
Error compiling layer:

Compile error: line 104, column 50: Can't reference member variable in non-class function
S2::NodeVarRef, S2/NodeVarRef.pm, 199
S2::NodeVarRef, S2/NodeVarRef.pm, 151
S2::NodeTerm, S2/NodeTerm.pm, 162
S2::NodeTerm, S2/NodeTerm.pm, 66
S2::NodeSum, S2/NodeSum.pm, 65
S2::NodeSum, S2/NodeSum.pm, 64
S2::NodeSum, S2/NodeSum.pm, 64
S2::NodeSum, S2/NodeSum.pm, 64
S2::NodeTerm, S2/NodeTerm.pm, 76
S2::NodeTerm, S2/NodeTerm.pm, 66
S2::NodeExpr, S2/NodeExpr.pm, 46
S2::NodePrintStmt, S2/NodePrintStmt.pm, 55
S2::NodeStmtBlock, S2/NodeStmtBlock.pm, 101
S2::NodeFunction, S2/NodeFunction.pm, 230
S2::Checker, S2/Checker.pm, 353
S2::Compiler, S2/Compiler.pm, 34

Context

100:
101:
102: function print_banner(Page p) {
103: container_open("banner");
104: print safe """ $p.global_title
""";
105: print safe """$p.global_subtitle
""";
106: container_close();
107: }
108:

Reply

av8rmike November 6 2007, 17:09:57 UTC
And that's why I shouldn't try to copy code from one layout to anyother without testing first. Try changing the first highlighted section to say $p.journal->base_url() instead of just $.journal->base_url() (yes, just one letter).

Reply

jaceman November 6 2007, 17:16:03 UTC
Excellent! Now, I just have to see if I'm smart enough to figure out how to re-style this back to the way it looked before we successfully created the links.

Thanks a lot.

P.S. Nice job in sneaking in the fix on the title AND the actual entries on me.

Reply

jaceman November 6 2007, 17:22:28 UTC
*tires screeching*

Actually, back the truck up.

While it's true that there are links now, they didn't quite do what I expected.

For example, I went to my latest entry, then clicked on my Blog title... I expected to return to the main page of my blog... instead I went to:

http://jaceman.livejournal.com/%3Cspan%20class='ljuser'%20lj:user='jaceman'%20style='white-space:%20nowrap;'%3E%3Ca%20href='http://jaceman.livejournal.com/profile'%3E%3Cimg%20src='http://stat.livejournal.com/img/userinfo.gif'%20alt='%5Binfo%5D'%20width='17'%20height='17'%20style='vertical-align:%20bottom;%20border:%200;%20padding-right:%201px;'%20/%3E%3C/a%3E%3Ca%20href='http://jaceman.livejournal.com/'%3E%3Cb%3Ejaceman%3C/b%3E%3C/a%3E%3C/span%3E-%3Ebase_url()

which reads:

The requested URL / jaceman->base_url() was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Reply

jaceman November 6 2007, 17:25:00 UTC
one other question so that I can help you to help me...

Apparently the tag "code" is not the right code to show code on the screen the way you did above all neatly formatted in the box. How did you do that? I'd like to know so that I can show you the EXACT code I have and where the errors are. It should make it easier to help you if I give you real information and not "faulty" stuff.

Thanks again!

Reply

av8rmike November 6 2007, 18:30:31 UTC
Just shoot me now.... usually I can get this stuff right on the first or second try. I just tried this in my own Bloggish layer, so I know it works. In the first highlighted part, replace $p.journal->base_url() with $p.base_url (no parentheses).

If you want to post code into entries and comments, the editor will automatically parse it for HTML tags, so you have to "escape" the HTML. This means telling the editor to print literal < and > symbols rather than interpreting them as HTML. There's a tool here that formats it automatically, but usually I just search and replace. The "neat box" is just
and tags.

Incidentally, that last line was entered as this: <pre> and <code>

Reply

jaceman November 6 2007, 19:18:12 UTC
Thanks friend! That's the ticket. Now we just see if I can actually get it styled the way I had it before. *fingers crossed*

Reply


Leave a comment

Up