Drupal custom login block and PHP smarty tags

Discussion in 'Integration' started by skippybosco, Oct 29, 2005.

  1. skippybosco

    skippybosco Guest

    After a couple of years of running Mambo I had a need to provide full html and css compliant content to support various clients such as mobile devices and disability devices.

    So the site is converted and I have created a custom block inside of Drupal to auto login to Amember for use with .htaccess / mod re-write protection. Very simple and documented elsewhere, but looks like this:

    Code:
    <?php
    if ($my->id) {
    	echo _HI; ?><?php echo $my->username;?>
    	<br />
    	<a href="<?php echo sefRelToAbs("/amember/logout.php"); ?>"><?php echo _BUTTON_LOGOUT; ?></a>
    	<br />
    	<a href="<?php echo sefRelToAbs("/amember/member.php"); ?>"><?php echo "Edit Profile"; ?></a>
    	<?php
    } else {
      ?>
    <form action="/amember/login.php" method=post>
    Username:
    <input type=text name=amember_login size=10>
    Password:
    <input type=password name=amember_pass size=12>
    
    <input type=submit value=Login>
    </form>
    
    <a href="http://{SITENAME.COM}/amember/signup.php">Sign Up Now</a> 
    	<?php
    }
    The problem I am having is that it does not seem to recognize the if "($my->id)" and as a result it always thinks it is logged in which removes my ability to put in custom "Edit Profile" links and such.

    I have this block marked as a PHP code block.

    Has anyone gotten this to work correctly so that Drupal modules or blocks could recognize the smarty session tags?

    Thanks!
    Frank
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Try line like:

    PHP:
    if ($my->username != "") {
  3. skippybosco

    skippybosco Guest

    thanks for the quick reply alex and for the advice. Tried adding the code you suggested with no luck. I'm thinking that this may be a Drupal or pathing issue as it appears to not understand the session stuff. Tried creating a custom page with just:

    Code:
    <?php echo $my->username;?>[code]
    
    and that also did not return any results.. I'll continue to debug in Drupal source to see if I can figure out what is happening..
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    Where did you get this code at all?

    PHP:
    <?php
    if ($my->id) {
        echo 
    _HI?><?php echo $my->username;?>
        <br />
        <a href="<?php echo sefRelToAbs("/amember/logout.php"); ?>"><?php echo _BUTTON_LOGOUT?></a>
        <br />
        <a href="<?php echo sefRelToAbs("/amember/member.php"); ?>"><?php echo "Edit Profile"?></a>
        <?php
    } else {
      
    ?>
    <form action="/amember/login.php" method=post>
    Username:
    <input type=text name=amember_login size=10>
    Password:
    <input type=password name=amember_pass size=12>

    <input type=submit value=Login>
    </form>

    <a href="http://{SITENAME.COM}/amember/signup.php">Sign Up Now</a> 
        <?php
    }
    It is not something related with aMember (except links)!

Share This Page