151 (edited by bingiman 2007-06-28 23:46)

Re: New frontpage index mod!

MattF wrote:

Looks like your script is gathering a following, Bingiman. big_smile Btw, apologies for not doing any updates on it over the last day or two. Got a tad sidetracked with another article/news cms I've been trying out. big_smile big_smile

I wish I could take credit for the script but it was originally Quaker's idea and we just shared ideas and sort of enhanced it from it's original state. Well, it was also possible by your work as well. As for not doing any updates, I understand. I myself have been very busy at work but I do look forward to seeing what you have in store for it.

Bingiman

Re: New frontpage index mod!

very nice.

registered and will point out a few things i noticed.

~James
FluxBB - Less is more

153

Re: New frontpage index mod!

All fixed Dr. Jeckyl

154 (edited by bingiman 2007-07-03 18:49)

Re: New frontpage index mod!

Something is wrong with this mod. There just has to be. I still have this problem where I am at post #15 but when I click on the main page to either "Edit", "Quote" or "Delete" the actual post it takes me to a completely different post. I do not have this issue while in viewtopic. I've asked soonotes to have a look at it for me so hopefully it can get resolved.

I think it is not reading the total amount of post in the different forums so the post count on the index is incorrect.

155

Re: New frontpage index mod!

bing email me the lastest version you got.
so i can see what up...

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

156

Re: New frontpage index mod!

<?php
 
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

//----------------------------------------------------------------------//

//These are the forums from which the news is retrieved
$forumids = array(1,3);

//This is the overall limit for how many news items will be displayed
$master_limit = '5';

//This is the amount of characters above which truncation will occur
$trunc_chars = '350';

//----------------------------------------------------------------------//

if ($pun_config['o_index_message_show'] == 1)
{
?>
    <div class="block">
        <h2><span><?php echo pun_htmlspecialchars($pun_config['o_index_message_head']) ?></span></h2>
        <div class="box">
            <div class="inbox">
            <?php echo $pun_config['o_index_message'] ?>
            </div>
        </div>
    </div>
<?php
}
?>
<div style="padding-bottom: 15px;padding-top: 8px;">
<?php
    include('mod_active_topics.php');
?></div>
<?php
//----------------------------------------------------------------------//

function close_tags($string)
{
    if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
    {
        $start_tags = $start_tags[1];

        if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
        {
            $complete_tags = array();
            $end_tags = $end_tags[1];

            foreach ($start_tags as $key => $val)
            {
                $posb = array_search ($val, $end_tags);
                if (is_integer ($posb))
                {
                    unset ($end_tags[$posb]);
                }
                else
                {
                    $complete_tags[] = $val;
                }
            }
        }
        else
        {
            $complete_tags = $start_tags;
        }

        $complete_tags = array_reverse ($complete_tags);
        for ($i = 0; $i < count ($complete_tags); $i++)
        {
            $string .= '</' . $complete_tags[$i] . '>';
        }
    }

        // Removes irrelevant tags
    $xhtml_tags = array ('</img>', '</hr>', '</br>');
    $string = str_replace ($xhtml_tags, '', $string);
    return $string;
}

//----------------------------------------------------------------------//

function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
$append = '...';

    if (strlen ($string) <= $length)
    {
        return $string;
    }
    else if ($length > 0)
    {
        preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
        $string = $matches[0];
        $string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
        return $string;
    }
}

//----------------------------------------------------------------------//

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$master_limit) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while($cur_post = $db->fetch_assoc($result))
    {
        echo '<div class="block">';
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
        }
        else
        {
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
        }

        $news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);

        if (pun_strlen($news_message) > $trunc_chars)
        {
            $news_message = truncate($news_message);
            $read_more = ' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
        }
        else
        {
            $read_more = ' | ';
        }

        if ($cur_post['num_replies'] != '0')
        {
            $replies = ' <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
        }
        else
        {
            $replies = ' Replies: '.$cur_post['num_replies'].' ';
        }

        echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
    <div class="box">
        <div class="inbox">
        <ul><li>
        <table width="100%" border="0">
            <tr>
            <td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
            </tr>
        </table> 
        <table width="100%" border="0">
            <tr>
            <td align="left" style="white-space: nowrap; width: 8em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?></td>
            <td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
            </tr>
        </table>
        <table class="news_footer" width="100%">
            <tr>
            <td>
<?php
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n";

                if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST)
                {
                    echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="white-space: nowrap; float:right">'.'<a href="misc.php?report='.$cur_post['id'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['id'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['id'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['id'].'">'.$lang_topic['Quote'].'</a>'.'</span>'."\n\n\n\n";
                }
?>
            </td>
            </tr>
        </table>       
        </li></ul>
        </div>
    </div>
</div>
<?php
    }
}
?>
        <div style="text-align: center;">Theme Designed by: Shedrock - <a onclick="window.open(this.href); return false;" href="http://shednotes.com">shednotes.com</a></div>
        <br/>
<?php

require PUN_ROOT.'footer.php';

?>

157

Re: New frontpage index mod!

Here is my completed version of the news index.php file. This one has all of the problems fixed as far as the Edit, Quote and Delete functions go. Thanks to soonotes

<?php
 
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

//----------------------------------------------------------------------//

//These are the forums from which the news is retrieved
$forumids = array(1,3);

//This is the overall limit for how many news items will be displayed
$master_limit = '5';

//This is the amount of characters above which truncation will occur
$trunc_chars = '350';

//----------------------------------------------------------------------//

function close_tags($string)
{
    if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
    {
        $start_tags = $start_tags[1];

        if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
        {
            $complete_tags = array();
            $end_tags = $end_tags[1];

            foreach ($start_tags as $key => $val)
            {
                $posb = array_search ($val, $end_tags);
                if (is_integer ($posb))
                {
                    unset ($end_tags[$posb]);
                }
                else
                {
                    $complete_tags[] = $val;
                }
            }
        }
        else
        {
            $complete_tags = $start_tags;
        }

        $complete_tags = array_reverse ($complete_tags);
        for ($i = 0; $i < count ($complete_tags); $i++)
        {
            $string .= '</' . $complete_tags[$i] . '>';
        }
    }

        // Removes irrelevant tags
    $xhtml_tags = array ('</img>', '</hr>', '</br>');
    $string = str_replace ($xhtml_tags, '', $string);
    return $string;
}

//----------------------------------------------------------------------//

function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
$append = '...';

    if (strlen ($string) <= $length)
    {
        return $string;
    }
    else if ($length > 0)
    {
        preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
        $string = $matches[0];
        $string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
        return $string;
    }
}

//----------------------------------------------------------------------//

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.id AS pid, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$master_limit) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while($cur_post = $db->fetch_assoc($result))
    {
        echo '<div class="block">';
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
        }
        else
        {
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
        }

      $news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);

        if (pun_strlen($news_message) > $trunc_chars)
        {
            $news_message = truncate($news_message);
            $read_more = ' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
        }
        else
        {
            $read_more = ' | ';
        }

        if ($cur_post['num_replies'] != '0')
        {
            $replies = ' <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
        }
        else
        {
            $replies = ' Replies: '.$cur_post['num_replies'].' ';
        }

echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
    <div class="box">
        <div class="inbox">
<ul><li>
<table width="100%" border="0">
    <tr>
        <td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
    </tr>
</table> 
<table width="100%" border="0">
    <tr>
        <td align="left" style="white-space: nowrap; width: 9em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?></td>
        <td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
    </tr>
</table>

    <div style="padding-bottom: 20px;" class="news_footer"><div style="padding: 5px 5px 0px 5px;">

<?php

                if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST){
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n\n\n\n";
                echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="white-space: nowrap; float:right">'.'<a href="misc.php?report='.$cur_post['pid'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['pid'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['pid'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['pid'].'">'.$lang_topic['Quote'].'</a>'.'</span></div></div>'."\n\n\n\n";
            }else{
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span></div></div>'."\n";
}
?>   
</li></ul>
        </div>
    </div>
</div>
<?php
    }
}

require PUN_ROOT.'footer.php';

?>

There were also changes to the news footer area so I have posted the classes that must reside in your stylesheet_cs.css file below:

/* News Links on index page */

.news_subject {
    background-color: inherit;
    color: #A8B055;
    font: 1.6em/1.7em Georgia, "Times New Roman", serif;
    text-decoration:none; 
}

a.news_subject:hover {
    background-color: inherit; 
    color: #ECA205;
    text-decoration: none;
    border-bottom:1px dotted #ECA205
}

.news_footer {
    background-color: #1D2435;
    color: inherit;
    border-top: 1px solid #313A50;
    border-left: 1px solid #313A50;
    border-bottom: 1px solid #313A50;
    border-right: 1px solid #313A50;
}

.byuser {
    font-weight: normal; 
    color: #A58B02; 
    background-color: inherit
}

.user {
    font-weight: normal; 
    color: #6C695D; 
    background-color: inherit
}

.poster {background-color: inherit; color: #8E94A3 }
a.poster {background-color: inherit; text-decoration: none; color: #8E94A3 }
a.poster:visited {background-color: inherit; text-decoration: none; color: #8E94A3 }
a.poster:hover {background-color: inherit; color: #FFFFFF; text-decoration: none; border-bottom: 1px solid #6C7283 }

158

Re: New frontpage index mod!

This is great. The only problem I'm having is the avatar image title text shows a long string of code instead of just the user name.

header=[<span class=\'box_username\'> dude07]body=[<span class=\'box_info\'>Title...

159

Re: New frontpage index mod!

Please refer to this post:

http://punbb.org/forums/viewtopic.php?pid=97356#p97356

Re: New frontpage index mod!

How do i do this if my forum is set as mydomain.com/forums?
cheers

161

Re: New frontpage index mod!

rename index.php to forum.php
take this code and create a index.php then edit the file to pull u r threads....

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

162

Re: New frontpage index mod!

with this mod it is best to install the Frontpage mod which is available on http://punres.org wiki. It is very simple to setup.

Bingiman

163 (edited by quaker 2007-07-22 21:06)

Re: New frontpage index mod!

do u mean mini portal system from the wiki?

http://wiki.punres.org/Miniportal

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

164

Re: New frontpage index mod!

yes, that's what I meant.

165

Re: New frontpage index mod!

Bing IM me...

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

166

Re: New frontpage index mod!

I am on MSN now..9:06pm Sunday

167 (edited by direction 2007-07-23 05:23)

Re: New frontpage index mod!

quaker wrote:

rename index.php to forum.php
take this code and create a index.php then edit the file to pull u r threads....

Sorry i'm a bit confuse could you give me more details on how i would get the threads on to the homepage

thanks

168

Re: New frontpage index mod!

ok
simple.....
ftp to site
rename index.php to forum.php
keep ftp open
open notepad  copy bing code to it. add the css part to ur css.
save this file as index.php upload it via ftp.
that it.

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: New frontpage index mod!

lol ok

change the index.php file in mydomain.com/forums/ to forum.php right?

then new file index.php with the code and save that in mydomain.php/forums/?

what css file do i edit and where?

then how do i get the threads display on my homepage/site?

sorry still confuse on your instructions, need better details

thanks for help!

170

Re: New frontpage index mod!

email me ur aim msn yim id...

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

171

Re: New frontpage index mod!

bingiman wrote:

Here is my completed version of the news index.php file. This one has all of the problems fixed as far as the Edit, Quote and Delete functions go. Thanks to soonotes

<?php
 
define('PUN_ROOT', './');
require_once PUN_ROOT.'include/common.php';
 
//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);

define('PUN_ALLOW_INDEX', 1);
require_once PUN_ROOT.'header.php';
require_once PUN_ROOT.'include/parser.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';

//----------------------------------------------------------------------//

//These are the forums from which the news is retrieved
$forumids = array(1,3);

//This is the overall limit for how many news items will be displayed
$master_limit = '5';

//This is the amount of characters above which truncation will occur
$trunc_chars = '350';

//----------------------------------------------------------------------//

function close_tags($string)
{
    if (preg_match_all ('/<([a-z]+)[ >]/', $string, $start_tags))
    {
        $start_tags = $start_tags[1];

        if (preg_match_all ('/<\/([a-z]+)>/', $string, $end_tags))
        {
            $complete_tags = array();
            $end_tags = $end_tags[1];

            foreach ($start_tags as $key => $val)
            {
                $posb = array_search ($val, $end_tags);
                if (is_integer ($posb))
                {
                    unset ($end_tags[$posb]);
                }
                else
                {
                    $complete_tags[] = $val;
                }
            }
        }
        else
        {
            $complete_tags = $start_tags;
        }

        $complete_tags = array_reverse ($complete_tags);
        for ($i = 0; $i < count ($complete_tags); $i++)
        {
            $string .= '</' . $complete_tags[$i] . '>';
        }
    }

        // Removes irrelevant tags
    $xhtml_tags = array ('</img>', '</hr>', '</br>');
    $string = str_replace ($xhtml_tags, '', $string);
    return $string;
}

//----------------------------------------------------------------------//

function truncate($string)
{
global $pun_config;
$trunc_chars = '350';
$length = $trunc_chars;
$append = '...';

    if (strlen ($string) <= $length)
    {
        return $string;
    }
    else if ($length > 0)
    {
        preg_match ('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$length.',}\b#U', $string, $matches);
        $string = $matches[0];
        $string = close_tags (preg_replace ('#\s*<[^>]+>?\s*$#', '', $string).$append);
        return $string;
    }
}

//----------------------------------------------------------------------//

$result = $db->query('SELECT t.id, t.subject, t.num_replies, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.forum_id, u.use_avatar, u.num_posts, u.registered, u.title, p.id AS pid, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted, g.g_title, f.forum_name FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON p.topic_id=t.id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id IN ('.implode(',', $forumids).') AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$master_limit) or error('Unable to fetch announcements', __FILE__, __LINE__, $db->error());

if ($db->num_rows($result))
{
    while($cur_post = $db->fetch_assoc($result))
    {
        echo '<div class="block">';
        if ($pun_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $pun_user['show_avatars'] != '0')
        {
            if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.gif" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.jpg" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
            else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png'))
            {
                $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img title="header=[<span class=\'box_username\'> '.pun_htmlspecialchars($cur_post['poster']).'] body=[<span class=\'box_info\'> Title: '.$cur_post['g_title'].'<br /> Total Post: '.$cur_post['num_posts'].'<br /> Registered Date: '. format_time($cur_post['registered'], true).']</span>" src="'.$pun_config['o_avatars_dir'].'/'.$cur_post['poster_id'].'.png" '.$img_size[3].' alt="'.$cur_post['poster'].'\'s Avatar" /></a>';
            }
        }
        else
        {
            $user_avatar = '<a href="profile.php?id=' . $cur_post['poster_id'] . '"><img src="img/noimage.gif" alt=""/></a>';
        }

      $news_message = parse_message($cur_post['message'], $cur_post['hide_smilies']);

        if (pun_strlen($news_message) > $trunc_chars)
        {
            $news_message = truncate($news_message);
            $read_more = ' | <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'">Read More</a> | ';
        }
        else
        {
            $read_more = ' | ';
        }

        if ($cur_post['num_replies'] != '0')
        {
            $replies = ' <a href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_post['id'].'#p'.$cur_post['last_post_id'].'">Replies</a>: '.$cur_post['num_replies'].' ';
        }
        else
        {
            $replies = ' Replies: '.$cur_post['num_replies'].' ';
        }

echo "\t\t\t\t\t\t\t".'<h2><strong><a href="forum.php">Forum</a> » <a href="viewforum.php?id='.$cur_post['forum_id'].'">'.pun_htmlspecialchars($cur_post['forum_name']).'</a>'.'</strong></h2>'."\n";
?>
    <div class="box">
        <div class="inbox">
<ul><li>
<table width="100%" border="0">
    <tr>
        <td style="border: 0px; padding: 0px 10px 7px 7px;"><a class="news_subject" href="viewtopic.php?id=<?php echo $cur_post['id']; ?>"><?php echo $cur_post['subject']; ?></a></td>
    </tr>
</table> 
<table width="100%" border="0">
    <tr>
        <td align="left" style="white-space: nowrap; width: 9em; padding-left: 7px; padding-top: 6px; padding-bottom: 30px; border: 0px;" valign="top"><?php echo $user_avatar ?></td>
        <td style="text-align: left; border: 0px; padding-top: 0px;" valign="top"><?php echo $news_message."\n" ?></td>
    </tr>
</table>

    <div style="padding-bottom: 20px;" class="news_footer"><div style="padding: 5px 5px 0px 5px;">

<?php

                if ($cur_post['poster_id'] == $pun_user['id'] || $pun_user['g_id'] < PUN_GUEST){
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span>'."\n\n\n\n";
                echo "\t\t\t\t\t\t\t".'<a href="viewtopic.php?id='.$cur_post['id'].'">'.pun_htmlspecialchars($lang_portal['Visit_Topic']).'</a>'.'<span style="white-space: nowrap; float:right">'.'<a href="misc.php?report='.$cur_post['pid'].'">'.$lang_topic['Report'].'</a>'.' | <a href="delete.php?id='.$cur_post['pid'].'">'.$lang_topic['Delete'].'</a> | <a href="edit.php?id='.$cur_post['pid'].'">'.$lang_topic['Edit'].'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'">'.'Reply'.'</a>'.' | <a href="post.php?tid='.$cur_post['id'].'&qid='.$cur_post['pid'].'">'.$lang_topic['Quote'].'</a>'.'</span></div></div>'."\n\n\n\n";
            }else{
                echo "\t\t\t\t\t\t\t".'<span class="user" style="float:left">Posted: '.format_time($cur_post['posted']).' by:<span class="user'.(isset($cur_post['g_title']) ? ' '.strtolower(str_replace(' ', '', $cur_post['g_title'])) : '').'"> <a class="poster" href="profile.php?id='.$cur_post['poster_id'].'">'.pun_htmlspecialchars($cur_post['poster']).'</a>'.$read_more.'Views: '.$cur_post['num_views'].' |'.$replies.'</span></span></div></div>'."\n";
}
?>   
</li></ul>
        </div>
    </div>
</div>
<?php
    }
}

require PUN_ROOT.'footer.php';

?>

There were also changes to the news footer area so I have posted the classes that must reside in your stylesheet_cs.css file below:

/* News Links on index page */

.news_subject {
    background-color: inherit;
    color: #A8B055;
    font: 1.6em/1.7em Georgia, "Times New Roman", serif;
    text-decoration:none; 
}

a.news_subject:hover {
    background-color: inherit; 
    color: #ECA205;
    text-decoration: none;
    border-bottom:1px dotted #ECA205
}

.news_footer {
    background-color: #1D2435;
    color: inherit;
    border-top: 1px solid #313A50;
    border-left: 1px solid #313A50;
    border-bottom: 1px solid #313A50;
    border-right: 1px solid #313A50;
}

.byuser {
    font-weight: normal; 
    color: #A58B02; 
    background-color: inherit
}

.user {
    font-weight: normal; 
    color: #6C695D; 
    background-color: inherit
}

.poster {background-color: inherit; color: #8E94A3 }
a.poster {background-color: inherit; text-decoration: none; color: #8E94A3 }
a.poster:visited {background-color: inherit; text-decoration: none; color: #8E94A3 }
a.poster:hover {background-color: inherit; color: #FFFFFF; text-decoration: none; border-bottom: 1px solid #6C7283 }
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

172

Re: New frontpage index mod!

Hello, first of all: Thank you so much for this mod.

I have a question: There is a way, to put in botton of this page generated by this mod, a NEXT / PREVIEW page button? To see more like a real blog page.

Thanks again smile

173

Re: New frontpage index mod!

are you talking about pagination? i didnt design it to do that. if that what you are looking for. you can alway call it news.php and at the botom add a link to new_tech.php or other pages you want to call it.


Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

174

Re: New frontpage index mod!

Thank you quaker

Yes, I'm talking about pagination. Like a real blog.

I will looking for if exist any mods that already do this in punres.

Thank you again smile

175

Re: New frontpage index mod!

Pagination was never added because it's not really in keeping with the concept. A frontpage for the forums is exactly that. Going to the forums will give you access to all the other info. Pagination on that index page would be severe overkill.