1 (edited by Tubby 2007-01-20 21:03)

Topic: Forum Description

Just sharing this with some of you tongue

this modification is rather simple and what it does is add a forum description block to viewforum.php depending on whether or not a description is set.

Add this to viewforum.php:

if($cur_forum['forum_desc'] != '')
    $forum_description = '<div class="block"><h2><span>Forum Description</span></h2><div class="box"><div style="margin: 3px" class="inbox"><strong>'.$cur_forum['forum_name'].':</strong> '.$cur_forum['forum_desc'].'</div></div></div>';
    else
    $forum_description = '';

Find this query:

$result = $db->query('SELECT f.forum_name, f.redirect_url, f.moderators, f.num_topics, f.sort_by, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());

Add this to the query:

f.forum_desc,

Find these lines:

<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
<?php echo $post_link ?>
        <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

Before these lines add this line:

<?php echo $forum_description ?>

As a result to the following step above you should have something like this:

<?php echo $forum_description ?>
<div class="linkst">
    <div class="inbox">
        <p class="pagelink conl"><?php echo $paging_links ?></p>
<?php echo $post_link ?>
        <ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
        <div class="clearer"></div>
    </div>
</div>

That should be it tongue let me know if you encounter any problems and i will see what steps i have missed.

2

Re: Forum Description

Maybe I'm a noob now, but wouldn't it be better with

if( empty( $cur_forum['forum_desc'] ) )

Instead of

if($cur_forum['forum_desc'] != '')

Re: Forum Description

http://www.php.net/empty

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

Re: Forum Description

Runar: I think you mean !empty wink
In any case, it doesn't really matter tongue