?

Log in

No account? Create an account

Previous Entry | Next Entry

Logged in indicator.

  • Sep. 13th, 2006 at 1:31 PM
I get annoyed with the toolbar that everyone seems to love, as it has too much stuff in too ugly of a style. So I've tried to intergrate as much of the functions I like into my style so I don't need it. The biggest thing is if I'm logged in or not. I'd fixed that in flexisquares with a "if( viewer_logged_in() ){ "x" } else { "y" } statement for a sidebar element. I'm trying to get it to work in expressive now, and I just can't figure it out.

I've got a paid account, I'm currently working with the sidebar organization solution offered by asciident in this comment, except applied to two columns.

I've tried it a couple different ways. Here's my working sidebar code before I tried to add my logged in? sidebar item:

set sidebar_primary = [
[ "userprofile", "Profile", "1", "1" ],
[ "calendar", "Latest Month" ],
[ "links", "Links" ],
];

set sidebar_secondary = [
[ "tags", "Tags" ],
[ "archive", "Page Summary" ],
[ "customtext", ">^..^<", "     "Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people."
     -George Bernard Shaw" ],
[ "syndicate", "Syndicate" ],
[ "poweredby" ],
];


And when I try to put the if else statement in outside of the sidebar element, like this:

set sidebar_secondary = [
if( viewer_logged_in() ){
[ "customtext", "logged in?", "Yay! We're logged in!" ],
} else {
[ "customtext", "logged in?", "Go log in, you loser!" ],
}
[ "tags", "Tags" ],
[ "archive", "Page Summary" ],
[ "customtext", ">^..^<", "     "Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people."
     -George Bernard Shaw" ],
[ "syndicate", "Syndicate" ],
[ "poweredby" ],
];


I get this error:

S2 Compiler Output at Wed Sep 13 20:16:01 2006
Error compiling layer:

Compile error: line 93, column 25: Expecting comma
S2::NodeArrayLiteral, S2/NodeArrayLiteral.pm, 59
S2::NodeTerm, S2/NodeTerm.pm, 458
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::NodeSet, S2/NodeSet.pm, 39
S2::Layer, S2/Layer.pm, 53
S2::Compiler, S2/Compiler.pm, 27


Context

89: [ "links", "Links" ],
90: ];
91:
92: set sidebar_secondary = [
93: if( viewer_logged_in() ){
94: [ "customtext", "logged in?", "Yay! We're logged in!" ],
95: } else {
96: [ "customtext", "logged in?", "Go log in, you loser!" ],
97: }



If I try to put it inside the sidebar element, like this:

set sidebar_secondary = [
[ "customtext", "logged in?", if( viewer_logged_in() ){ "Yay! We're logged in!" } else { "Go log in, you loser!" } ],
[ "tags", "Tags" ],
[ "archive", "Page Summary" ],
[ "customtext", ">^..^<", "     "Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people."
     -George Bernard Shaw" ],
[ "syndicate", "Syndicate" ],
[ "poweredby" ],
];


I get this error:

S2 Compiler Output at Wed Sep 13 19:58:47 2006
Error compiling layer:

Compile error: line 93, column 59: Expecting comma
S2::NodeArrayLiteral, S2/NodeArrayLiteral.pm, 59
S2::NodeTerm, S2/NodeTerm.pm, 458
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::NodeArrayLiteral, S2/NodeArrayLiteral.pm, 62
S2::NodeTerm, S2/NodeTerm.pm, 458
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::NodeSet, S2/NodeSet.pm, 39
S2::Layer, S2/Layer.pm, 53
S2::Compiler, S2/Compiler.pm, 27


Context

89: [ "links", "Links" ],
90: ];
91:
92: set sidebar_secondary = [
93: [ "customtext", "logged in?", if( viewer_logged_in() ){ "Yay! We're logged in!" } else { "Go log in, you loser!" } ],
94: [ "tags", "Tags" ],
95: [ "archive", "Page Summary" ],
96: [ "customtext", ">^..^<", "     \"Reasonable people adapt themselves to the world. Unreasonable people attempt to adapt the world to themselves. All progress, therefore, depends on unreasonable people.\"
97:      -George Bernard Shaw" ],


If anyone knows how to fix one or the other error, or if you can fix both tell me which is the better way to do it, I'd greatly appreciate it. Once I can get this squared away, I can see about getting html working in the sidebar without having to make my own copy of the expressive style layer so that I can make the "log in" link to the log in page. The html in the sidebar isn't worth cutting myself off from updates to the style.

Thanks in advance.

Comments

( 9 comments — Leave a comment )
nimoloth
Sep. 13th, 2006 10:23 pm (UTC)
I think the problem there is that you're trying to put function code (i.e. if-then-else) into the bit at the top where you can only define and set variable.

As a hack (there are probably more elegant and complicated ways to do this that I don't know yet) you can put this little snippet of code into the function for wherever you want it to show up:

if( viewer_logged_in() ){
"""<h3 class="widget-header">Login Status</h3>""" ;
"""<ul class="widget-list"><li class="item"><a href="http://diziara.livejournal.com">Yay! We're logged in!</a></li></ul>""" ;
} else {
"""<h3 class="widget-header">Login Status</h3>""" ;
"""<ul class="widget-list"><li class="item"><a href="http://www.livejournal.com/login.bml">Go log in, you loser!</a></li></ul>""";
}

Since you say you are using a custom theme rather than a custom layer, you will need to paste in an entire function. So, if you want it to appear below the custom text module in the sidebar, you can put this:

function print_module_customtext(string title, string text, string titlelink_url) {
var Page p = get_page();
open_module("customtext", $title, $titlelink_url);
print safe $text;

if( viewer_logged_in() ){
"""<h3 class="widget-header">Login Status</h3>""" ;
"""<ul class="widget-list"><li class="item"><a href="http://diziara.livejournal.com">Yay! We're logged in!</a></li></ul>""" ;
} else {
"""<h3 class="widget-header">Login Status</h3>""" ;
"""<ul class="widget-list"><li class="item"><a href="http://www.livejournal.com/login.bml">Go log in, you loser!</a></li></ul>""";
}

close_module();
}


Hopefully that is of some use to you. If you look up the source code for Expressive, you can find the other print_module options and put it in one of them if you want. Or anywhere really.
diziara
Sep. 13th, 2006 10:43 pm (UTC)
You rock so hard. ^_^ And now that I have that little bit of code, I can do other things I wanted too. Thank you!
nimoloth
Sep. 13th, 2006 10:49 pm (UTC)
You're welcome! I hope it works. I must stop LJ-ing now and do some actual work...
diziara
Sep. 13th, 2006 11:25 pm (UTC)
Hmm, playing with it further to get more sidebar modules with html in them, I can't get anything other than the modules chained together in the same part of the sidebar. If I put the function print_module_customtext block twice, it only shows the first one. If I try to rename to print_module_customtext2 it tells me I can't define items in the theme layer. So am I stuck with all html based sidebar modules in a chain, or is there something else I can do?

I have everything moved around so that it can work as is, so you don't have to reply 'til you've got some of your much needed actual work done, but I would be happier if I can have my logged in module above my summary module, and everything else below it. So if you have any ideas, or need more information, please let me know. Otherwise, I'll keep hacking at it and see if I get lucky. ^_^
nimoloth
Sep. 13th, 2006 11:41 pm (UTC)
Well, if you use a custom layer instead of a custom theme (with the Expressive source code pasted into it) you will be able to rename and create new modules. A theme can only override what already exists.

To get it above the summary, you could insert it into the print_module_pagesummary function in the right place, probably right at the top of it. Do you know how to change the order of sidebar elements? You can change the order by changing the order of these:

function prop_init() {
if (viewer_sees_vbox()) {
$*sidebar_primary = [
[ "userprofile", "Profile", "1", "1" ],
[ "calendar", "Latest Month" ],
[ "ads", "" ],
];
$*sidebar_secondary = [
[ "links", "Links" ],
[ "tags", "Tags" ],
[ "archive", "Page Summary" ],
[ "syndicate", "Syndicate" ],
[ "poweredby" ],
[ "customtext", "Custom Text Title", "This is your free text space, put what you want here, cannot use HTML..." ],
]
];
}
}
diziara
Sep. 13th, 2006 11:55 pm (UTC)
I already have been playing with the order of the sidebar modules, I just haven't had to shuffle too much around as the two sidebar layout wasn't too badly thought out, even though the single bar is absolutely moronic in order.

Putting it into the summary module will probably work best as I like the order pretty well now, other than wanting my login module at the top of that sidebar, but the rest of the stuff I'm adding elsewhere.

I should be able to find everything I need to override that in the source layer, huh? *goes to muck* Thanks for the help, hopefully I'll get it this time. ^_^
nimoloth
Sep. 14th, 2006 12:00 am (UTC)
Yeah, just look for print_page_summary - that's the function you're looking for.
diziara
Sep. 14th, 2006 01:22 am (UTC)
Wee, I got it. I decided instead of attaching the logged in module to the page summary, I attached the other two modules to the powered by module. Anyways, I did want to let you know I got it all like I want it now. Thanks for your help and patience with me. ^_^
nimoloth
Sep. 13th, 2006 11:43 pm (UTC)
[Note that if you only have a one sidebar layout, all those modules appear in it, in that order, not just the ones specified for that sidebar.]
( 9 comments — Leave a comment )

Latest Month

March 2016
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031  

S2 Help Communities

Tags

Powered by LiveJournal.com
Designed by chasethestars