Miniportal

From PunBB Resource Wiki

Jump to: navigation, search

Author: Connorhd of MyPunBB.com

This addon to PunBB is split up into 2 sections, the first is adding a portal page to your forum, and the second is adding a menu to the lefthand side of your forum, both work together however you do not need to install them both.

Contents

Part 1: Adding a portal page

This adds a portal page to your site which consists of a welcome message and a list of news items taken from a forum of your choice.

Step 1: Rename index.php

Rename index.php to forum.php

Step 2: Create a new index.php

Create a new index.php based on the one below

<?php
 
define('PUN_ROOT', './');
define('PUN_FRONT', 1);
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
 
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
 
function pun_news($fid='', $show=15, $truncate=1)
{
    global $lang_common, $db, $pun_config, $db_prefix;
    $max_subject_length = 30;
    $show_max_topics = 50;
    $fid = intval($fid);
    $order_by = 't.posted';
    $forum_sql = '';
 
    // Was a forum ID supplied?
    if ( $fid ) $forum_sql = 'f.id='.$fid.' AND ';
    $show = intval($show);
    if ($show < 1 || $show > $show_max_topics)
    $show = 15;
    $saveddate = '';
 
    // Fetch $show topics
    $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post, f.id AS fid, f.forum_name FROM '.$db_prefix.'topics AS t INNER JOIN '.$db_prefix.'forums AS f ON t.forum_id=f.id WHERE f.id='.$fid.' AND t.moved_to IS NULL ORDER BY '.$order_by.' DESC') or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());
    $show_count = 0;
 
    if (!$db->num_rows($result)) return $output;
    while (($show_count < $show) && ($cur_topic = $db->fetch_assoc($result))) {
        $temp = array();
		$output = array();
        if ($pun_config['o_censoring'] == '1')
            $cur_topic['subject'] = censor_words($cur_topic['subject']);
        if (pun_strlen($cur_topic['subject']) > $max_subject_length)
            $subject_truncated = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).' ...';
        else
            $subject_truncated = $cur_topic['subject'];
        $newsheading = '<a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&amp;action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject_truncated).'</a> - <em>Posted by '.$cur_topic['poster'].' at '.date('h:i A', $cur_topic['posted']).'</em><br />';
        // Group posts by date    
        $thisdate = date('l, d F Y', $cur_topic['posted']);
        if ($thisdate != $saveddate) 
 
        {
            if ($saveddate)
            {
                $temp[] = "</div></div>";
            }
            $temp[] = '<div class="block"><h2><span>'.$thisdate.'</span></h2><div class="box"><div class="inbox"><p>';
            $saveddate = $thisdate;
        }
        else {
            $temp[] = '<div class="inbox"><p>';
        }
        $temp[] = $newsheading.'</p><p>';
        $id = $cur_topic['id'];
        $msg = $db->query('SELECT id, poster, poster_id, poster_ip, poster_email, message, posted, edited, edited_by FROM '.$db_prefix.'posts WHERE topic_id='.$id.' LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
            if ( !$db->num_rows($msg) ) continue;
        $cur_post = $db->fetch_assoc($msg);
        // Display first paragraph only (comment out next four lines to turn off)
        if ($truncate == 1)
        {
        $paragraph = preg_split('/s*n+/', $cur_post['message']);
            if (isset($paragraph[1])) {
                $cur_post['message'] = $paragraph[0] . '...';
            }
        }
        $cur_post['message'] = parse_message($cur_post['message'], 0);
        $temp[] = $cur_post['message'];
        $temp[] = '</p></div>';
        if (isset($output)) {
            $output[] = implode(' ', $temp);
        }
        else {
            $output[] = implode(' ', $temp);
        }
        ++$show_count;
    } // end of while
    $output[] = '</div></div>';
    return implode(' ', $output);
}
?>
 
        <div class="block">
            <h2><span>Welcome</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent augue. Nulla facilisi. Fusce bibendum accumsan erat. Quisque sollicitudin mattis neque. Sed dapibus. Integer a lectus eu sem consequat pellentesque. Morbi rhoncus nulla. Duis adipiscing interdum velit. Fusce ante. Ut vitae enim sit amet magna sodales hendrerit. In sed tortor at sapien convallis eleifend. Proin mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut metus. Cras ac arcu et arcu porttitor blandit. Nam vitae lectus eget mauris sollicitudin placerat. Suspendisse vestibulum. Donec varius libero. Duis velit tellus, euismod vitae, consequat sed, consectetuer ut, purus.
                    </p>
                    <p>
                    Praesent viverra venenatis magna. Etiam in dolor. Ut in justo ac nibh malesuada cursus. Duis urna arcu, aliquam vitae, consequat nec, tincidunt non, mi. Nunc lobortis. Nunc pharetra. Sed porttitor. Maecenas turpis tortor, blandit nec, dignissim in, porttitor eu, odio. In hac habitasse platea dictumst. Suspendisse augue odio, ornare a, elementum ac, tincidunt varius, orci. Nulla libero ante, hendrerit ac, consectetuer eu, sollicitudin et, eros. Duis sapien. Suspendisse ornare enim sit amet dui. Donec ullamcorper diam.
                    </p>
                </div>
            </div>
        </div>
<?php
echo pun_news(1, 5, 0);
 
require PUN_ROOT.'footer.php';

The welcome block can contain anything you want, including html,

"pun_news(1, 5, 0)" is the news generator the syntax is: pun_news(forum id, number of news to display, truncate news);

Step 3: Add forums.php to nav links

Add forums.php to the menu:

Login to your forum. Go to Administration and then Administration Options.

Find the "Additional menu Items" and add this line: 1 = <a href="forum.php">Forum</a>


Step 4: Replace forum index links

Replace links to the forum index in viewtopic and viewforum

simply open up both viewforum.php and viewtopic.php and replace index.php with forum.php you should have to replace it twice in both

also replace it in header.php, you will find it once in there.

Note: You can update $lang_common['Index'] to $lang_common['Forum'] on these pages so it says "Forum >> Topic" instead of "Index >> Topic" if you prefer since your index is no longer the forum page.

You now have a portal page on your punbb site :)

Part 2: Adding a sidebar

How to add a sidebar (you do not need part 1 to use part 2)

Step 1: Replace main.tpl

replace main.tpl with

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html dir="<pun_content_direction>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<pun_char_encoding>" />
<pun_head>
<style type="text/css">
    #left {
        width: 120px;
        float: left;
    }
    #main {
        margin-left: 130px;
    }
    #container {
        width: 100%;
        float: right;
        margin-left: -120px;
    }
</style>
</head>
<body>
 
<div id="punwrap">
<div id="pun<pun_page>" class="pun">
 
<div id="brdheader" class="block">
    <div class="box">
        <div id="brdtitle" class="inbox">
            <pun_title>
            <pun_desc>
        </div>
        <pun_navlinks>
        <pun_status>
    </div>
</div>
 
<div id="container">
    <div id="main">
 
        <pun_announcement>
 
        <pun_main>
 
    </div>    
</div>
 
<div id="left">    
    <div class="block">
        <h2><span>Menu</span></h2>
        <div class="box">
        <pun_sidelinks>            
        </div>
    </div>
    <div class="block">
        <h2 class="block2"><span>More Links</span></h2>
        <div class="box">
            <div class="inbox">
                <ul>
                    <li><a href="index.php">Link 1</a></li>
                    <li><a href="index.php">Link 2</a></li>
                    <li><a href="index.php">Link 3</a></li>
                    <li><a href="index.php">Link 4</a></li>
                </ul>        
            </div>
        </div>
    </div>
</div>
 
<div class="clearer"></div>
 
<pun_footer>
 
</div>
</div>
 
</body>
</html>

Step 2: Open header.php

open header.php

find

// START SUBST - <pun_navlinks>
$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_navlinks>

after add

// START SUBST - <pun_sidelinks>
$tpl_main = str_replace('<pun_sidelinks>','<div class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_sidelinks>

that will add a sidebar on the left with the navlinks from the top plus some extra links which you can change/remove

Additional Blocks

These are blocks to be added to the sidebar you created in Part 2, you must have Part 2 to install this

Whos Online Block

Step 1: open header.php

open header.php

find the code you added before

// START SUBST - <pun_sidelinks>
$tpl_main = str_replace('<pun_sidelinks>','<div class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_sidelinks>

after add

// START SUBST - <pun_online>
$tpl_main = str_replace('<pun_online>','<div class="inbox">'."\n\t\t\t". generate_whosonline()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_online>

Step 2: add to functions.php

add this to functions.php (the end is fine)

//
// Generate the whos online block
//
function generate_whosonline()
{
    global $pun_config, $lang_common, $pun_user, $db;
 
    if ($pun_user['is_guest'])
    {
        require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
        return 'Welcome Guest!<br />
            Please login.<br />
            <form id="login" method="post" action="login.php?action=in" onsubmit="return process_form(this)">
                <input type="hidden" name="form_sent" value="1" />
                <input type="hidden" name="redirect_url" value="index.php" />
                <label><strong>Username</strong><br /><input type="text" name="req_username" size="13" maxlength="25" tabindex="1" /><br /></label>
                <label><strong>Password</strong><br /><input type="password" name="req_password" size="13" maxlength="16" tabindex="2" /><br /></label>
                <p><a href="register.php" tabindex="4">'.$lang_login['Not registered'].'</a><br />
                <a href="login.php?action=forget" tabindex="5">'.$lang_login['Forgotten pass'].'</a></p>
                <p><input type="submit" name="login" value="Login" tabindex="3" /></p>
            </form>';
    }
    else
    {
        require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
        $result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
        $stats['total_users'] = $db->result($result);
 
        $result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
        $stats['last_user'] = $db->fetch_assoc($result);
 
        $result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
        list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);
 
        if ($pun_config['o_users_online'] == '1')
        {
            // Fetch users online info and generate strings for output
            $num_guests = 0;
            $users = array();
            $online = array();
            $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());
 
            while ($pun_user_online = $db->fetch_assoc($result))
            {
                if ($pun_user_online['user_id'] > 1)
                    $users[] = "\n\t\t\t\t".'<a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a><br />';
                else
                    ++$num_guests;
            }
 
            $num_users = count($users);
            $online[] = "\t\t\t\t".$lang_index['Users online'].': <strong>'.$num_users.'</strong><br />'."\n\t\t\t\t".$lang_index['Guests online'].': <strong>'.$num_guests.'</strong>'."\n\t\t\t"."\n";
 
 
            if ($num_users > 0 && $num_users < 10)
                $online[] = "\t\t\t"."\n\t\t\t\t".'<br /><strong>'.$lang_index['Online'].':&nbsp;</strong>'."\t\t\t\t".implode($users)."\n";
            else
                $online[] = "\t\t\t".'<div class="clearer"></div>'."\n";
 
        }
 
        return 'Welcome <strong>'.$pun_user['username'].'</strong><br /><br />
            '.implode($online,'').'<br />
            Users: <strong>'. $stats['total_users'].'</strong><br />
            Topics: <strong>'.$stats['total_topics'].'</strong><br />
            Posts: <strong>'.$stats['total_posts'].'</strong><br />';
    }
}

Step 3: open main.tpl

then within

<div id="left">
.....
</div>

in main.tpl

add

<div class="block">
        <h2 class="block2"><span>Whos Online?</span></h2>
        <div class="box">
        <pun_online>
        </div>
</div>

You will also need to replace the css at the top of main.tpl with this:

<style type="text/css">
    #left {
        width: 140px;
        float: left;
    }
    #main {
        margin-left: 150px;
    }
    #container {
        width: 100%;
        float: right;
        margin-left: -140px;
    }
</style>

this will add something along the lines of

Welcome Connorhd

Registered users online: 1
Guests online: 0

Online: 
Connorhd

Users: 1
Topics: 3
Posts: 3

Top Posters Block

Step 1: Open header.php

open header.php Insert the following into the appropriate section of the header (around line 150)

// START SUBST - <pun_toppost>
    $tpl_temp=top_poster();
    $tpl_main = str_replace('<pun_toppost>',$tpl_temp, $tpl_main);
// END SUBST - <pun_toppost>

Step 2: Open functions.php

open functions.php Insert the following at the end.

function top_poster()
{
    global $lang_common, $db, $pun_config, $db_prefix;
 
    $result = $db->query('SELECT username, num_posts, id FROM '.$db_prefix.'users WHERE id > 1 ORDER BY num_posts DESC LIMIT 5') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
 
    $outhtml='<div class="block"><h2><span>Top Posters</span></h2><div class="box">';
    $outhtml=$outhtml.'<div class="inbox">';
		while ($cur_post = $db->fetch_assoc($result))
    {
          $outhtml.='<div class="inbox"><a href="profile.php?id='.$cur_post['id'].'">'.$cur_post['username'].'</a><div><strong>Posts:</strong> '.$cur_post['num_posts'].'</div></div>';			
    }    
    $outhtml.='</div>';
    $outhtml.='</div></div>';
    return $outhtml;
}

To change the number of top poster's displayed, edit DESC LIMIT 5' to an appropriate integer.

Step 3: Open main.tpl

Open main.tpl

In the appropriate section (after the Who's Online block) add:

<div class="block">
         <pun_toppost>
    </div>

This will add the top 5 posters, with post count and a link to their profile.

username
Posts: xx

username
Posts: xx

username
Posts: xx

Username
Posts:xx

username
Posts:xx

Login Block

Step 1: Create a new file under include/user

create a new file under include/user and name it login.php


Step 2: Open your new login.php file

Now open up your new login.php file, apply this code to it, and save it.

<?php
 
// Show login if not logged in
if($pun_user['is_guest'])
{
    if(!isset($focus_element) || (isset($focus_element) && !in_array('login', $focus_element)))
    {
 
    // Load the language files
    require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
    require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
 
    // Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
    $redirect_url = (isset($_SERVER['HTTP_REFERER']) && preg_match('#^'.preg_quote($pun_config['o_base_url']).'/(.*?)\.php#i', $_SERVER['HTTP_REFERER'])) ? htmlspecialchars($_SERVER['HTTP_REFERER']) : 'index.php';
 
    $required_fields = array('req_username' => $lang_common['Username'], 'req_password' => $lang_common['Password']);
 
?>
                  <div class="block">
 
<h2><span>Login</span></h2>
<div id="login" class="box">
<div class="inbox">             
        <div class="logintop">
            <form id="login" name="login" name="qpost" method="post" action="login.php?action=in" onsubmit="return process_form(this)">
<div style="text-align: center" class="inform">
 
 
 
 
 
 
 
                <p>
                    <input type="hidden" name="form_sent" value="1" />
                    <input type="hidden" name="redirect_url" value="<?php echo $redirect_url ?>" />
                     <?php echo $lang_common['Username'] ?><br />
                    <input type="text" name="req_username" size="16" maxlength="25" /><br /><br />
                    &nbsp;<?php echo $lang_common['Password'] ?><br />
 
 <input type="password" name="req_password" size="16" maxlength="16" wrap="virtual" onkeypress="if(event.keyCode==13) document.login.submit()" /><br /><br />
<input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" /><br /><br />
                    <a href="register.php"><?php echo 'Register Now!'; ?></a>
                </p>
 
</div>
            </form>
        </div>
</div>
</div>
</div>
<?php
    }
}


Step 3: Open up your tpl file

Open up your tpl file that controls the miniportal sidebar and simply add this code somewhere along the sidebar.

<pun_include "login.php">

New page template

You can add new pages using your template in multiple ways. One easy way is to now use the Custom Pages Mod at http://www.punres.net/desc.php?pid=165. Or you can use this template and just create a new page each time you need another content page.

<?php
 
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / New page 1';
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
 
?>
        <div class="block">
            <h2><span>Box 1</span></h2>
            <div class="box">
                <div class="inbox">
                    <p>
                    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent augue. Nulla facilisi. Fusce bibendum accumsan erat. Quisque sollicitudin mattis neque. Sed dapibus. Integer a lectus eu sem consequat pellentesque. Morbi rhoncus nulla. Duis adipiscing interdum velit. Fusce ante. Ut vitae enim sit amet magna sodales hendrerit. In sed tortor at sapien convallis eleifend. Proin mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut metus. Cras ac arcu et arcu porttitor blandit. Nam vitae lectus eget mauris sollicitudin placerat. Suspendisse vestibulum. Donec varius libero. Duis velit tellus, euismod vitae, consequat sed, consectetuer ut, purus.
                    </p>
                    <p>
                    Praesent viverra venenatis magna. Etiam in dolor. Ut in justo ac nibh malesuada cursus. Duis urna arcu, aliquam vitae, consequat nec, tincidunt non, mi. Nunc lobortis. Nunc pharetra. Sed porttitor. Maecenas turpis tortor, blandit nec, dignissim in, porttitor eu, odio. In hac habitasse platea dictumst. Suspendisse augue odio, ornare a, elementum ac, tincidunt varius, orci. Nulla libero ante, hendrerit ac, consectetuer eu, sollicitudin et, eros. Duis sapien. Suspendisse ornare enim sit amet dui. Donec ullamcorper diam.
                    </p>
                </div>
            </div>
        </div>
<?php
 
require PUN_ROOT.'footer.php';


Part 5: Support

You can ask any questions in the forum at http://www.punres.net/viewtopic.php?id=1172 as needed.

A fix for the "Mark all topics as read" etc links

This will allow you to see the "Mark all topics as read" etc. links on the forum page, or, with the other code, on all pages.

if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php')))
		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
	else
		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
if (in_array(basename($_SERVER['PHP_SELF']), array('forum.php', 'search.php')))
		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';
	else
		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';

• change to (for all fix)

		$tpl_temp .= "\n\t\t\t".'</ul>'."\n\t\t\t".'<ul class="conr">'."\n\t\t\t\t".'<li><a href="search.php?action=show_new">'.$lang_common['Show new posts'].'</a></li>'."\n\t\t\t\t".'<li><a href="misc.php?action=markread">'.$lang_common['Mark all as read'].'</a></li>'."\n\t\t\t".'</ul>'."\n\t\t\t".'<div class="clearer"></div>'."\n\t\t".'</div>';

left and right blocks

You can ask any questions in the forum at http://forums.punbb.org/viewtopic.php?pid=90598#p90598 as needed.

Open your include/template/main.tpl file and copy this over your existing one.

    <style type="text/css">
 
#left {
    float:left;
    width: 150px;
    overflow: hidden;
}
 
#right {
    float:right;
    width: 150px;
    overflow: hidden;
}
 
#main { 
    display: block; 
    overflow: hidden; 
    width: auto; 
    padding-left: 5px; 
    padding-right: 5px; 
    margin-left: 1px; 
    margin-right: 1px;
}

Side bar nav

This gives you the control to add links to your sidebar nav. and keep your menu bar clean and un-junky with tons of links. Specail thanks goes out to Mark, and Elbekko for there help with the SQL part!

<tr>
    <th scope="row">Additional menu items</th>
    <td>
            <textarea name="form[additional_navlinks]" rows="3" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_additional_navlinks']) ?></textarea>
            <span>By entering HTML hyperlinks into this textbox, any number of items can be added to the navigation menu at the top of all pages. The format for adding new links is X = &lt;a href="URL"&gt;LINK&lt;/a&gt; where X is the position at which the link should be inserted (e.g. 0 to insert at the beginning and 2 to insert after "User list"). Separate entries with a linebreak.</span>
   </td>
</tr>
<tr>
    <th scope="row">Additional Sidenav menu items</th>
    <td>
            <textarea name="form[additional_sidenav]" rows="3" cols="55"><?php echo pun_htmlspecialchars($pun_config['o_additional_sidenav']) ?></textarea>
            <span>By entering HTML hyperlinks into this textbox, any number of items can be added to the navigation menu at the top of all pages. The format for adding new links is X = &lt;a href="URL"&gt;LINK&lt;/a&gt; where X is the position at which the link should be inserted (e.g. 0 to insert at the beginning and 2 to insert after "User list"). Separate entries with a linebreak.</span>
    </td>
</tr>
// START SUBST - <pun_navlinks>
$tpl_main = str_replace('<pun_navlinks>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_navlinks>
// START SUBST - <pun_sidenav>
$tpl_main = str_replace('<pun_sidenav>','<div class="inbox">'."\n\t\t\t". generate_sidenav()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_sidenav>
//
// Generate the "navigator" that appears at the top of every page
//
function generate_navlinks()
{
	global $pun_config, $lang_common, $pun_user;
 
	// Index and Userlist should always be displayed
	$links[] = '<li id="navindex"><a href="index.php">'.$lang_common['Index'].'</a>';
	$links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';
 
	if ($pun_config['o_rules'] == '1')
		$links[] = '<li id="navrules"><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a>';
 
	if ($pun_user['is_guest'])
	{
		if ($pun_user['g_search'] == '1')
			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
 
		$links[] = '<li id="navregister"><a href="register.php">'.$lang_common['Register'].'</a>';
		$links[] = '<li id="navlogin"><a href="login.php">'.$lang_common['Login'].'</a>';
 
		$info = $lang_common['Not logged in'];
	}
	else
	{
		if ($pun_user['g_id'] > PUN_MOD)
		{
			if ($pun_user['g_search'] == '1')
				$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
 
			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
			$links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
		}
		else
		{
			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
			$links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>';
			$links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
		}
	}
 
	// Are there any additional navlinks we should insert into the array before imploding it?
	if ($pun_config['o_additional_navlinks'] != '')
	{
		if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
		{
			// Insert any additional links into the $links array (at the correct index)
			for ($i = 0; $i < count($extra_links[1]); ++$i)
				array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i]));
		}
	}
 
	return '<ul>'."\n\t\t\t\t".implode($lang_common['Link separator'].'</li>'."\n\t\t\t\t", $links).'</li>'."\n\t\t\t".'</ul>';
}
//
// Generate the "navigator" that appears at the side of every page
//
function generate_sidenav()
{
	global $pun_config, $lang_common, $pun_user;
 
	// Index and Userlist should always be displayed
	$links[] = '<li id="navindex"><a href="index.php">'.$lang_common['Index'].'</a>';
	$links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';
 
	if ($pun_config['o_rules'] == '1')
		$links[] = '<li id="navrules"><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a>';
 
	if ($pun_user['is_guest'])
	{
		if ($pun_user['g_search'] == '1')
			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
 
		$links[] = '<li id="navregister"><a href="register.php">'.$lang_common['Register'].'</a>';
		$links[] = '<li id="navlogin"><a href="login.php">'.$lang_common['Login'].'</a>';
 
		$info = $lang_common['Not logged in'];
	}
	else
	{
		if ($pun_user['g_id'] > PUN_MOD)
		{
			if ($pun_user['g_search'] == '1')
				$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
 
			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
			$links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
		}
		else
		{
			$links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
			$links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
			$links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>';
			$links[] = '<li id="navlogout"><a href="login.php?action=out&amp;id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
		}
	}
 
	// Are there any additional navlinks we should insert into the array before imploding it?
	if ($pun_config['o_additional_sidenav'] != '')
	{
		if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_sidenav']."\n", $extra_links))
		{
			// Insert any additional links into the $links array (at the correct index)
			for ($i = 0; $i < count($extra_links[1]); ++$i)
				array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i]));
		}
	}
 
	return '<ul>'."\n\t\t\t\t".implode($lang_common['Link separator'].'</li>'."\n\t\t\t\t", $links).'</li>'."\n\t\t\t".'</ul>';
}
<pun_sidenav>

Run this query, and remember, if you have a prefix, put that before config or you will get an error :)

INSERT INTO config (conf_name, conf_value) VALUES ('o_additional_sidenav', 'this data');

Now all you need to do is go into your admin_options page and add links to your hearts content :)

--Mark 01:14, 18 January 2008 (GMT)

Quaker (Scot)

Elbekko (Ben)

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox