Tuesday, April 24, 2012

PHP, html, and Css

You should have a general understanding of PHP, HTML, and CSS before you create a drupal template or else you could wreck your site ;).

Login/Logout link for Drupal 7




<!--this php code goes in the page.tpl.php or in a block with php filter -->
<?php global $user; if (!$user->uid) {  
print "<a href='http://".$base_path."/user' >login</a>"; }   
else { 
print "<a href='http:// ".$base_path."/user/logout' >logout</a>"; 
} ?>
Sorry, I had the wrong php code here, the above code is correct, I tested it on my site.

-edit- Redid the code to include the sitename, no need to change anything now. :)