Topic: How to edit main.tpl so only members can see links

Im using the main.tpl file to show a logo/links at the top of the website. How would I have certain links only be displayed for people who are logged into the forums? How about people of certain groups?

Re: How to edit main.tpl so only members can see links

That would require PHP, which you can't use in main.tpl wink You can make a placeholder and then replace it in header.php.

Something like this:
main.tpl
<links>

header.php

if($pun_user['is_guest'])
{
str_replace('<links>', 'Your links go in here', $tpl_main);
}
else
{
str_replace('<links>', '', $tpl_main);
}

Re: How to edit main.tpl so only members can see links

elbekko, why not just edit functions.php? Sounds simpler to me (busy now though so I can't post anything in terms of code at the moment).

Looking for a certain modification for your forum? Please take a look here before posting.

Re: How to edit main.tpl so only members can see links

Yes, but I think he was doing it somewhere else...

Re: How to edit main.tpl so only members can see links

elbekko wrote:

Yes, but I think he was doing it somewhere else...

Ah, I see what you're saying. Ooops.

Though IMO it might be easier just to put whatever the links are in a PHP file in include/user, then use <pun_include=file.php> in main.tpl (no messing with header.php)

Looking for a certain modification for your forum? Please take a look here before posting.

Re: How to edit main.tpl so only members can see links

elbekko wrote:

Something like this:
main.tpl
<links>

Instead of using <links>, I used <glink1>. Should this still work? I believe I tried it but yet I had no results. However I wanna be sure that I fully understand what you were saying smile

pogenwurst wrote:

Though IMO it might be easier just to put whatever the links are in a PHP file in include/user, then use <pun_include=file.php> in main.tpl (no messing with header.php)

How would the punbb determine if the user is a guest, member, or a member from a certain group?

Im slowly learning php so excuse me if I seem a bit 'new'.

Would I be doing something like

if($pun_user['is_guest'])
{
<a href="http://www.google.com"><img src="link"></a>
}
else
{
}

Re: How to edit main.tpl so only members can see links

<a href="http://www.google.com"><img src="link"></a>

Make that

echo '<a href="http://www.google.com"><img src="link"></a>'

and you're getting the hang of it smile

8 (edited by KinXen 2006-05-09 02:23)

Re: How to edit main.tpl so only members can see links

ALRIGHT!!! WOOOOOOOOOHOOOOOOO!

I feel so happy now, smile



Although I have one last question. How would I set it so only members from certain groups see the link?

This is what I did, however it doesn't seem to work.

if($pun_user['group_id 1'])

Here is an example on how its used

<?php

if($pun_user['is_guest'])
{
echo '<a href="http://www.google.com"><img src="http://www.google.com/intl/en/images/logo.gif"></a>';
}

if($pun_user['group_id 1'])
{
echo '<a href="http://www.google.com"><img src="http://www.google.com/intl/en/images/logo.gif"></a>';
}

?>

Re: How to edit main.tpl so only members can see links

if($pun_user['group_id 1'])

Change that to

if($pun_user['g_id'] == 1)

10

Re: How to edit main.tpl so only members can see links

works great! thank you