help with side navigation

Started by 1MileCrash, July 22, 2005, 01:26:03 PM

Previous topic - Next topic

1MileCrash

Im trying to get a side navigation bar on my forum. I already have the table set up, but adding the content is provideing me with some difficulties..

First problem, is that the links look horrorble aligned all the way to the top. Bloc instructed me to add style="padding-top: 30px;" to the <td>. Well, that worked, but now it seems that my <BR>'s are skipping 30 px...why is that? And how can i fix it?

Second, how can i make some links display only when a user is logged in? I used this for the admincp, and that worked just peachy-
' , $context['user']['is_admin'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '
how can i do the exact same thing, but for when a user is logged in? This isnt really a problem, just something i dont know how to do.  :P
The only thing php can't do is tell you how much milk is left in the fridge.



codenaught

Quote from: Tippmaster on July 22, 2005, 01:26:03 PM
Second, how can i make some links display only when a user is logged in? I used this for the admincp, and that worked just peachy-
' , $context['user']['is_admin'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '
how can i do the exact same thing, but for when a user is logged in? This isnt really a problem, just something i dont know how to do.  :P

You can use is_logged.
Dev Consultant
Former SMF Doc Coordinator

1MileCrash

okay, thanks. It worked.

For the opisite, i would use is_guest?

And what is the url for log out? I put it as index.php?action=logout , but i get "session verification failed. Dont i need sessionid or something in the url? How do i do that?  :-[
The only thing php can't do is tell you how much milk is left in the fridge.



codenaught

The default usage for the logout code is: <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">

And yes, you can use is_guest.
Dev Consultant
Former SMF Doc Coordinator

1MileCrash

Thank You! Everything worked perfectly. Exept one small thing, which im sure is a simple error on my part. When i am logged out, i see both the log in and log out buttons, and when i am either logged in or out, their is a gap where the url's im not supposed to see would be. Im guessing i added a <br> or two where it shouldnt be.

This is my code-
<td width="10%" bgcolor="a9a9a9"><A HREF="index.php">Home</A><br><A HREF="index.php?action=help">Help</A><br><A HREF="index.php?action=search">Search</A><br>' , $context['user']['is_guest'] ? '<a href="index.php?action=login">Log In</a>' : '' , '<br>' , $context['user']['is_guest'] ? '<a href="index.php?action=register">Register</a>' : '' , '<br>' , $context['user']['is_admin'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '<br>' , $context['user']['is_logged'] ? '<a href="index.php?action=profile">Profile</a>' : '' , '<br><a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">Log Out</A></td>
    <td width="90%">';
The only thing php can't do is tell you how much milk is left in the fridge.



1MileCrash

nvm, i found out what was wrong with my log out link, but now, when i put it the right way, i am getting a parse error  >:(

what i added is in red. Anybody notice what's wrong?

Quote<td width="10%" bgcolor="a9a9a9"><A HREF="index.php">Home</A><br><A HREF="index.php?action=help">Help</A><br><A HREF="index.php?action=search">Search</A><br>' , $context['user']['is_guest'] ? '<a href="index.php?action=login">Log In</a>' : '' , '<br>' , $context['user']['is_guest'] ? '<a href="index.php?action=register">Register</a>' : '' , '<br>' , $context['user']['is_admin'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '<br>' , $context['user']['is_logged'] ? '<a href="index.php?action=profile">Profile</a>' : '' , '<br>' , $context['user']['is_logged'] ? '<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">Log Out</a>' : '' , '</td>
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

Use dots instead of commas in some parts..from this:
$context['user']['is_logged'] ? '<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">Log Out</a>' : '' , '</td>

to this:
$context['user']['is_logged'] ? '<a href="'. $scripturl. '?action=logout;sesc='. $context['session_id']. '">Log Out</a>' : '' , '</td>

1MileCrash

still a parse error. Is it just really picky, or is something wrong?

Quote<td width="10%" bgcolor="a9a9a9" style="padding-top: 30px;" valign="top"><center><A HREF="index.php">Home</A><br><A HREF="index.php?action=unread">New Posts</A><br>' , $context['user']['is_logged'] ? '<a href="index.php?action=profile">Profile</a>' : '' , '<br><A HREF="index.php?action=help">Help</A><br><A HREF="index.php?action=search">Search</A><br>' , $context['user']['is_guest'] ? '<a href="index.php?action=login">Log In</a>' : '' , '<br>' , $context['user']['is_guest'] ? '<a href="index.php?action=register">Register</a>' : '' , '<br>' , $context['user']['is_admin'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '<br>$context['user']['is_logged'] ? '<a href="'. $scripturl. '?action=logout;sesc='. $context['session_id']. '">Log Out</a>' : '' , '</center></td>

added part in read. Bloc's code.
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

um..this part:
Admin</a>' : '' , '<br>$context['user']['is_logged']
should be:
Admin</a>' : '' , '<br>' , $context['user']['is_logged']

Easy to skip one of those... ;)

1MileCrash

*slaps his forhead*

that worked just fine. Thanks for your patience.

now for my new "problem"  :P

It appears as though when i am logged in, i see a gap (a line break) where the hidden links (register, log out) would appear. So should i skip those line breaks? Or could i put the line break inside the url? I never tried that before, so im not sure if it would work, something like, <A HREF="somthing.htm"><br>The displayed Text</A>
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

Not inside the link part, but right before/after perhaps? --> </a><br /> or <br /><a href...

1MileCrash

ahhh, you mean to where it's before the commas and dashes and stuff, what you said earlier is starting click now, because if it's in that, than it will only show it if it is true or whatever. But if is outside of it, it will show regardless. Right? Am i catching on or just not making any sense?
The only thing php can't do is tell you how much milk is left in the fridge.



1MileCrash

yep, that worked perfectly. All i have to do now is make the text in the side nav. pretty, i can do that.  :)

That, and im going to need to know how to remove the current menu.

lol, im such a noob.
The only thing php can't do is tell you how much milk is left in the fridge.



bloc

hehe..we have all been there. PHP seemed greek to me at first...

1MileCrash

:0

almost forgot, what is the url used for the calendar? like, i want to show it only if it is enabled, so i'd need some command thingy...
The only thing php can't do is tell you how much milk is left in the fridge.



codenaught

Default Usage:

// The [calendar]!
if ($context['allow_calendar'])
echo '
<a href="', $scripturl, '?action=calendar">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/calendar.gif" alt="' . $txt['calendar24'] . '" style="margin: 2px 0;" border="0" />' : $txt['calendar24']), '</a>', $context['menu_separator'];


So you would need if ($context['allow_calendar'])
Dev Consultant
Former SMF Doc Coordinator

1MileCrash

so implement it the same way? Something Like-
if ($context['allow_calendar'])  ? '<a href="index.php?action=admin">Admin</a>' : '' , '

or totally no..?
The only thing php can't do is tell you how much milk is left in the fridge.



[Unknown]

Quote from: Tippmaster on July 22, 2005, 10:58:01 PM
so implement it the same way? Something Like-
if ($context['allow_calendar'])  ? '<a href="index.php?action=admin">Admin</a>' : '' , '

or totally no..?

That should be, looking at it only mind you, either:

$context['allow_calendar'] ? '<a href="index.php?action=admin">Admin</a>' : '' , '

Or:

if ($context['allow_calendar']) echo '<a href="index.php?action=admin">Admin</a>'; echo '

-[Unknown]

1MileCrash

i just "eyeballed" it and got lucky.

i used this-
' , $context['allow_calendar'] ? '<a href="index.php?action=calendar>Calendar</a>

or something like that. It worked okay.
The only thing php can't do is tell you how much milk is left in the fridge.



Advertisement: