1 (edited by bingiman 2007-11-01 00:01)

Topic: Adding a link to user profile in main.tpl

Is it possible for me to add a link to the user profile in main.tpl? If so, then how would I go about doing it?


Actually, It is in an external file located in the include/user folder.

Here is the code:

<?php

// Slider Menu
global $pun_config, $lang_common, $pun_user;

if ($pun_config['o_show_slider'] == '1')
{
?>
<script type="text/javascript">
window.addEvent('domready', function() {
            var myMenu = new ImageMenu($$('#slider .slider'),{openWidth:215});
});
</script>
        <div id="sliders_container" align="center">
            <div id="slider" align="center">
                      <ul class="sliders">
        <li><a style="width: 95px;" href="search.php?action=show_new" class="slider opt1" ><span>Latest Posts</span></a></li>
        <li><a style="width: 95px;" href="news.php" class="slider opt2"><span>News</span></a></li>
<?php

if ($pun_user['is_guest']){
        echo '<li><a style="width: 95px;" href="register.php" class="slider opt3_register"><span>Images</span></a></li>';
        }else{
        echo '<li><a style="width: 95px;" href="uploadimg.php" class="slider opt3"><span>Images</span></a></li>';
        }
?>
        <li><a style="width: 95px;" href="downloads.php" class="slider opt4"><span>Downloads</span></a></li>
        <li><a style="width: 95px;" href="page.php?id=3" class="slider opt5"><span>Rules</span></a></li>
        <li><a style="width: 95px;" href="profile.php?id='.$pun_user['id'].'"" class="slider opt6"><span>Profile</span></a></li>
                </ul>
            </div>
        </div> 
<?php
}

Thanks
Bingiman.

2

Re: Adding a link to user profile in main.tpl

What's not working within that script at the moment?

3 (edited by bingiman 2007-11-01 02:46)

Re: Adding a link to user profile in main.tpl

The script works. This is the problem:

href="profile.php?id='.$pun_user['id'].'"

It can't read this line: '.$pun_user['id'].'"  - It just shows up exactly like that. I am guessing that I would also need a db query in there to grab the user info? I have no clue how to do it.

4

Re: Adding a link to user profile in main.tpl

Change that to:

href="profile.php?id="<?php echo $pun_user['id'] ?>"

Re: Adding a link to user profile in main.tpl

It doesn't work. This is all I get: http://192.168.0.104/profile.php?id=

6

Re: Adding a link to user profile in main.tpl

Comment out the global line.

Re: Adding a link to user profile in main.tpl

That still doesn't make a difference. sad

Re: Adding a link to user profile in main.tpl

I found the problem. You had: id=" and the quote should not have been there.

Thanks Matt

Bingiman

Re: Adding a link to user profile in main.tpl

Can someone please help me to format this line of code. I cannot get it to work no matter what I try. It is driving me mental.

<?php
if ($pun_user['is_guest']){
        echo '<li><a style="width: 95px;" href="register.php" class="slider opt3_register"><span>Profile</span></a></li>';
        else
        echo '<li><a style="width: 95px;" href="profile.php?id=<?php echo $pun_user['id'] ?>" class="slider opt6"><span>Profile</span></a></li>';
}
?>

I keep getting this error:

Parse error: parse error, unexpected T_ELSE in c:\punbb\include\user\slider_menu.php on line 30

Re: Adding a link to user profile in main.tpl

That's because you've nested the else inside the if. Written like that, you will only get to the else if the if is true. (euh, worst explanation ever) Just remove the curly braces and you should be fine. smile

Re: Adding a link to user profile in main.tpl

I got it.

<?php
if ($pun_user['is_guest']){ ?>

        <li><a style="width: 95px;" href="register.php" class="slider opt3_register"><span>Profile</span></a></li>
    <?php } else { ?>
        <li><a style="width: 95px;" href="profile.php?id=<?php echo $pun_user['id'] ?>" class="slider opt6"><span>Profile</span></a></li>
<?php } ?>