if you create two links, login and logout the corect desitnations, i.e /logout, put them in any menu you like. And drupal will only show login if user is an anonymous user and will only show logout if the user is an authenticated user
I guess you don't mean the existing user login block, which does that, but just a link which you can place wherever you want. Try this in your theme's page.tpl.php file, at the position that you want:
About mixing html and php, you can see that the page.tpl.php template file is html containing php snippets. You can do the same in any post if you have enabled the "php filter" module and select the "php code" input format when editing that post. Or you can just "print" html inside the php.
If you did this in a node, notice what I wrote above about the "php filter" module and the "php code" input format.
Also, to make it work in a node you need to add a global $user; line before your code, otherwise $user will be considered a local variable which has no value.
You can't run php code when the input format is not "php code". It just won't run. But you can enter html or anything you want when it is.
Also, $user is an object, not a sting, so you can't just print it. You can print $user->uid (user ID) or $user->name or $user->mail. To see what is available to print, you can do this:
Comments
you can check user object for
you can check user object for logged in state
http://api.drupal.org/api/global/user
The pages are in HTML, is
The pages are in HTML, is there a way to mix php and html in one page.
Thx
i think drupal should do it
i think drupal should do it automatically,
if you create two links, login and logout the corect desitnations, i.e /logout, put them in any menu you like. And drupal will only show login if user is an anonymous user and will only show logout if the user is an authenticated user
I guess you don't mean the
I guess you don't mean the existing user login block, which does that, but just a link which you can place wherever you want. Try this in your theme's page.tpl.php file, at the position that you want:
About mixing html and php, you can see that the page.tpl.php template file is html containing php snippets. You can do the same in any post if you have enabled the "php filter" module and select the "php code" input format when editing that post. Or you can just "print" html inside the php.
I looked at page.tpl and
I looked at page.tpl and played with php in html but it didn't work?
New page, select full HTML filter, add
print $userto the page, it displayprint $userIf you did this in a node,
If you did this in a node, notice what I wrote above about the "php filter" module and the "php code" input format.
Also, to make it work in a node you need to add a
global $user;line before your code, otherwise $user will be considered a local variable which has no value.The filter if html because I
The filter if html because I have html code there and just need to insert php code in html?
This is test
print $userI guess I need an example of php code in html code?
Also I tried menu link to logout/login, the logout works but the login doesn't?
=-=
If you add php you have to use the PHP input format even when there is HTML in the node. Otherwise the php is stripped from display.
anytime php is added into a node, the php input format must be used to correctly run the php
You can't run php code when
You can't run php code when the input format is not "php code". It just won't run. But you can enter html or anything you want when it is.
Also, $user is an object, not a sting, so you can't just print it. You can print
$user->uid(user ID) or$user->nameor$user->mail. To see what is available to print, you can do this:Got it, thx guys
Got it, thx guys