Holy stinking crap, did this just get added to the official extensions database? I got an upgrade notification for my own extension... =o
1 2008-12-04 19:50
Re: [Extension release] 1.3 Final - Active Topics list on Index (15 replies, posted in PunBB 1.3 extensions)
2 2008-12-03 11:35
Re: [Extension release] 1.3 Final - Active Topics list on Index (15 replies, posted in PunBB 1.3 extensions)
Hm, you know, I think I'm just going to (almost) entirely rewrite the code for the next version. This was based mostly on a code snip from Slavok, and it's really really sloppy. I could probably chop it down to 1/10th the size and make the code a lot more readable for the next version. I'll keep this tab open so I remember to get started on it... eventually. =\
3 2008-12-02 22:12
Re: [Extension release] 1.3 Final - Active Topics list on Index (15 replies, posted in PunBB 1.3 extensions)
Moving it below the forum listing? Looks like it should be possible by replacing:
<hook id="in_main_output_start">
with:
<hook id="in_end">
in "manifest.xml", then reinstalling the extension.
There are different hooks all throughout index.php, that put the script in at different places. I just really don't want to go through the hassle of uninstalling, reinstalling, uninstalling, then reinstalling, on my board, to test it. It looks like in_end is the right place to get it below the forum output though. Let me know how it works!
4 2008-12-02 17:54
Topic: [Extension release] 1.3 Final - Active Topics list on Index (15 replies, posted in PunBB 1.3 extensions)
*huff* About darn time this extension made it out of the shop. A much needed add-on for forums that need an attention-grabber.
I have no idea about performance implications, as it was a pain-in-the-arse enough just getting the stupid thing working! The design of this forum is very unconductive to adding or rearranging page elements, as I had to make this work without editing any of the existing stylesheet. Seeing as though, thanks to the genius that decided to inject CSS into every aspect of PunBB, the whole page layout is constructed in CSS, all I could really do is recycle and abuse other existing CSS classes and hope it doesn't break.
Seriously: fixed-defining the positions of elements to "fake" a table out of a list element is doin it rong. Very "rong".
Anyway, on with the show.
Create a new folder in your extensions folder, call it "active_topics". Save the following code as "manifest.xml":
<?xml version="1.0" encoding="utf-8"?>
<extension engine="1.0">
<id>active_topics</id>
<title>Active Topics List on Index</title>
<version>1.2</version>
<description>This will add the x most recent posts to the index page of the forum for easy navigation and attention-grabbing.</description>
<author>Slavok and FalconFour</author>
<minversion>1.3</minversion>
<maxtestedon>1.3</maxtestedon>
<install>
<![CDATA[
]]>
</install>
<uninstall>
<![CDATA[
]]>
</uninstall>
<hooks>
<hook id="in_main_output_start"><![CDATA[
$topics_count = 5;
$query_active_topics= array(
'SELECT' => 't.id AS tid, t.poster, t.subject, t.posted AS has_posted, t.last_post, t.last_post_id, t.num_replies, t.num_views, t.closed, t.sticky, t.forum_id, t.last_poster',
'FROM' => 'topics AS t',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'f.id=t.forum_id'
),
array(
'LEFT JOIN' => 'forum_perms AS fp',
'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
)
),
'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1)',
'ORDER BY' => 't.last_post DESC',
'LIMIT' => $topics_count
);
$result_active = $forum_db->query_build($query_active_topics) or error(__FILE__, __LINE__);
if ($forum_db->num_rows($result_active) == 0) {
?>
<div class="main-content main-message">
<p>There are no active topics.</p>
</div>
<?php
} else {
require_once FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php';
?>
<div class="main-subhead">
<p class="item-summary">
<span>
<strong class="subject-title"><?php echo $lang_index['Topics']; ?></strong>
<strong class="info-replies"><?php echo $lang_forum['Replies']; ?></strong>
<strong class="info-views"><?php echo $lang_forum['Views']; ?></strong>
<strong class="info-lastpost"><?php echo $lang_index['last post']; ?></strong>
</span>
</p>
</div>
<div class="main-content main-forum">
<?php
$item_num = 1;
while ($cur_set = $forum_db->fetch_assoc($result_active))
{
// Start from scratch
$item_subject = $item_body = $item_status = $item_nav = $item_title = array();
$item_indicator = '';
if (!empty($item_nav))
$item_title['nav'] = '<span class="item-nav">'.sprintf($lang_forum['Topic navigation'], implode('  ', $item_nav)).'</span>';
if ($cur_set['sticky'] == '1')
{
$item_subject_status['sticky'] = $lang_forum['Sticky'];
$item_status['sticky'] = 'sticky';
}
if ($cur_set['closed'] != '0')
{
$item_subject_status['closed'] = $lang_forum['Closed'];
$item_status['closed'] = 'closed';
}
if (!empty($item_subject_status))
$item_title['status'] = '<span class="item-status">'.sprintf($lang_forum['Item status'], implode(' ', $item_subject_status)).'</span>';
$item_title['link'] = '<a href="'.forum_link($forum_url['post'], $cur_set['last_post_id']).'">'.forum_htmlencode($cur_set['subject']).'</a>';
if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_set['has_posted'] > 0)
{
$item_title['posted'] = '<span class="posted-mark">'.$lang_forum['You posted indicator'].'</span>';
$item_status['posted'] = 'posted';
}
$item_body['subject']['title'] = '<h3 class="hn"><span class="item-num">'.forum_number_format(++$item_num).'</span> '.implode(' ', $item_title).'</h3> <em> by '.forum_htmlencode($cur_set['poster']).'</em>';
// Does this topic contain posts we haven't read? If so, tag it accordingly.
if (!$forum_user['is_guest'] && $cur_set['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_set['tid']]) || $tracked_topics['topics'][$cur_set['tid']] < $cur_set['last_post']) && (!isset($tracked_topics['forums'][$cur_set['forum_id']]) || $tracked_topics['forums'][$cur_set['forum_id']] < $cur_set['last_post']))
{
$item_status['new'] = 'new';
}
$item_body['subject']['desc'] = implode(' ', $item_subject);
if (empty($item_status))
$item_status['normal'] = 'normal';
$item_style = (($item_num % 2 != 0) ? ' odd' : ' even').(($item_num == 1) ? ' main-first-item' : '').((!empty($item_status)) ? ' '.implode(' ', $item_status) : '');
$item_body['info']['replies'] = '<li class="info-replies"><strong>'.forum_number_format($cur_set['num_replies']).'</strong> <span class="label">'.(($cur_set['num_replies'] == 1) ? $lang_forum['Reply'] : $lang_forum['Replies']).'</span></li>';
$item_body['info']['views'] = '<li class="info-replies"><strong>'.forum_number_format($cur_set['num_views']).'</strong> <span class="label">'.(($cur_set['num_views'] == 1) ? $lang_forum['View'] : $lang_forum['Views']).'</span></li>';
$item_body['info']['last_post'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_set['last_post_id']).'">'.format_time($cur_set['last_post']).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_set['last_poster'])).'</cite></li>';
?>
<div class="main-item<?php echo $item_style ?>">
<span class="icon <?php echo implode(' ', $item_status) ?>"><!-- --></span>
<div class="item-subject">
<?php echo implode("\n\t\t\t\t", $item_body['subject'])."\n" ?>
</div>
<ul class="item-info">
<?php echo implode("\n\t\t\t\t", $item_body['info'])."\n" ?>
</ul>
</div>
<?php
}
}
]]></hook>
</hooks>
</extension>
Change $topics_count = 5 in the first line of the hook script, to however many topics you want to show in the list.
Go to your extensions page, and hit install.
Enjoy!
Now, time for me to lay off the CSS for a while before my mind melts out my ears.
Version history:
1.0 - First version (unreleased)
1.1 - Made "new posts" indicator work properly
1.2 - Fixed the "item status" (closed, sticky) indicators appear properly. Made the list respect permissions, which is kinda important if you have an active moderator forum
5 2008-12-02 17:19
Re: Active Topics list... (13 replies, posted in PunBB 1.3 additions)
I made an installable extension out of it... yay!
But since there is no documentation on how to create an extension (which I'm sure is a huge hangup in the extensions community, not to mention the obscure and impossible to manipulate choice of using a fully CSS-based page design), I took an existing broken beta extension, and wrapped the code around it with a hook.
<?xml version="1.0" encoding="utf-8"?>
<extension engine="1.0">
<id>active_topics</id>
<title>Active Topics List on Index</title>
<version>1.1</version>
<description>This will add the x most recent posts to the index page of the forum for easy navigation and attention-grabbing.</description>
<author>Slavok and FalconFour</author>
<minversion>1.3</minversion>
<maxtestedon>1.3</maxtestedon>
<install>
<![CDATA[
]]>
</install>
<uninstall>
<![CDATA[
]]>
</uninstall>
<hooks>
<hook id="in_main_output_start"><![CDATA[
$topics_count = 5;
$query_active_topics= array(
'SELECT' => 't.id AS tid, t.poster, t.subject, t.posted AS has_posted, t.last_post, t.last_post_id, t.num_replies, t.num_views, t.closed, t.sticky, t.forum_id, t.last_poster',
'FROM' => 'topics AS t',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'f.id=t.forum_id'
),
array(
'LEFT JOIN' => 'forum_perms AS fp',
'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
)
),
'ORDER BY' => 't.last_post DESC',
'LIMIT' => $topics_count
);
$result_active = $forum_db->query_build($query_active_topics) or error(__FILE__, __LINE__);
if ($forum_db->num_rows($result_active) == 0) {
?>
<div class="main-content main-message">
<p>There is no message.</p>
</div>
<?php
} else {
require_once FORUM_ROOT.'lang/'.$forum_user['language'].'/forum.php';
?>
<div class="main-subhead">
<p class="item-summary">
<span>
<strong class="subject-title"><?php echo $lang_index['Topics']; ?></strong>
<strong class="info-replies"><?php echo $lang_forum['Replies']; ?></strong>
<strong class="info-views"><?php echo $lang_forum['Views']; ?></strong>
<strong class="info-lastpost"><?php echo $lang_index['last post']; ?></strong>
</span>
</p>
</div>
<div class="main-content main-forum">
<?php
$item_num = 1;
while ($cur_set = $forum_db->fetch_assoc($result_active))
{
// Start from scratch
$item_subject = $item_body = $item_status = $item_nav = $item_title = array();
$item_indicator = '';
if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_set['has_posted'] > 0)
{
$item_title['posted'] = '<span class="posted-mark">'.$lang_forum['You posted indicator'].'</span>';
$item_status['posted'] = 'posted';
}
$item_title['link'] = '<a href="'.forum_link($forum_url['post'], $cur_set['last_post_id']).'">'.forum_htmlencode($cur_set['subject']).'</a>';
if (!empty($item_nav))
$item_title['nav'] = '<span class="item-nav">'.sprintf($lang_forum['Topic navigation'], implode('  ', $item_nav)).'</span>';
$item_body['subject']['title'] = '<h3 class="hn"><span class="item-num">'.forum_number_format(++$item_num).'</span> '.implode(' ', $item_title).'</h3> <em> by '.forum_htmlencode($cur_set['poster']).'</em>';
if ($cur_set['sticky'] == '1')
{
$item_subject_status['sticky'] = $lang_forum['Sticky'];
$item_status['sticky'] = 'sticky';
}
if ($cur_set['closed'] != '0')
{
$item_subject_status['closed'] = $lang_forum['Closed'];
$item_status['closed'] = 'closed';
}
// Does this topic contain posts we haven't read? If so, tag it accordingly.
if (!$forum_user['is_guest'] && $cur_set['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_set['tid']]) || $tracked_topics['topics'][$cur_set['tid']] < $cur_set['last_post']) && (!isset($tracked_topics['forums'][$cur_set['forum_id']]) || $tracked_topics['forums'][$cur_set['forum_id']] < $cur_set['last_post']))
{
$item_status['new'] = 'new';
}
if (!empty($item_subject_status))
$item_subject['status'] = '<span class="item-status">'.sprintf($lang_forum['Item status'], implode(' ', $item_subject_status)).'</span>';
// $item_subject['starter'] = '<span class="item-starter">'.sprintf($lang_forum['Topic starter'], '<cite>'.forum_htmlencode($cur_set['poster']).'</cite>').'</span>';
$item_body['subject']['desc'] = implode(' ', $item_subject);
if (empty($item_status))
$item_status['normal'] = 'normal';
$item_style = (($item_num % 2 != 0) ? ' odd' : ' even').(($item_num == 1) ? ' main-first-item' : '').((!empty($item_status)) ? ' '.implode(' ', $item_status) : '');
$item_body['info']['replies'] = '<li class="info-replies"><strong>'.forum_number_format($cur_set['num_replies']).'</strong> <span class="label">'.(($cur_set['num_replies'] == 1) ? $lang_forum['Reply'] : $lang_forum['Replies']).'</span></li>';
$item_body['info']['views'] = '<li class="info-replies"><strong>'.forum_number_format($cur_set['num_views']).'</strong> <span class="label">'.(($cur_set['num_views'] == 1) ? $lang_forum['View'] : $lang_forum['Views']).'</span></li>';
$item_body['info']['last_post'] = '<li class="info-lastpost"><span class="label">'.$lang_index['Last post'].'</span> <strong><a href="'.forum_link($forum_url['post'], $cur_set['last_post_id']).'">'.format_time($cur_set['last_post']).'</a></strong> <cite>'.sprintf($lang_index['Last poster'], forum_htmlencode($cur_set['last_poster'])).'</cite></li>';
?>
<div class="main-item<?php echo $item_style ?>">
<span class="icon <?php echo implode(' ', $item_status) ?>"><!-- --></span>
<div class="item-subject">
<?php echo implode("\n\t\t\t\t", $item_body['subject'])."\n" ?>
</div>
<ul class="item-info">
<?php echo implode("\n\t\t\t\t", $item_body['info'])."\n" ?>
</ul>
</div>
<?php
}
}
]]></hook>
</hooks>
</extension>
Create a new folder in "extensions" called "active_topics", and save the above code as "manifest.xml".
Honestly though, I think I might be switching to either PunBB 1.2, which is more properly and cleanly supported, or just dropping PunBB altogether, since it seems its developers don't even know what's going on!
6 2008-12-02 16:17
Re: Active Topics list... (13 replies, posted in PunBB 1.3 additions)
Ahh, I found the problem. It wasn't that I wanted to remove the indicator for a sticky topic (that's like taking out the "service engine" bulb...), but rather that I wanted to figure out why it was saying all the topics were sticky.
The problem was that it wasn't actually showing the most recent topics, but rather just showing seemingly random topics. A little database browsing revealed that it wasn't showing random topics... rather, it was showing the least recent (oldest) topics by sorting the wrong way!
I changed line 16 to show 'ORDER BY' => 't.last_post DESC', and it showed the proper topics, and it also got rid of "Sticky:" on all the posts, because none of the recent topics were sticky.
Funny thing is, only two of the oldest topics shown were sticky... I think maybe it's accidentally flagging all the results as sticky, or maybe showing "Sticky" from that point on (perhaps by setting sticky = true instead of checking sticky == true?). I'll do a little more figuring on that.
7 2008-12-02 08:41
Re: Active Topics list... (13 replies, posted in PunBB 1.3 additions)
Hm, that's odd, maybe we're not talking about the same version. In my version (regular ol' 1.3), I've only got one (relevant) instance of the term "brd-main" in all the source code (used a file-search), and that's in functions.php that generates the header...
But I'll try putting it after "($hook = get_hook('in_main_output_start')) ? eval($hook) : null;", see how that works.
edit: Well, it worked... now I just need to figure out how to make it smaller, and fix the "sticky" thing.
edit: Wait, shoot, those aren't even the last 7 topics... hmm.
*back to the drawing board* I think I can figure it out though...
8 2008-12-02 05:20
Re: [Extension release] Last post subject on index (51 replies, posted in PunBB 1.3 extensions)
Yeah, don't bother trying to install it, it's very broken. I tried my best to get it fixed, and there were a lot (a lot) of code changes that seemingly broke 1.3 Beta extensions. There's even an error that completely prevents it from being uninstalled without editing the database (as you solve each of the problems it presents, one of the errors is in the uninstaller, which is executed from the database).
Augh.
9 2008-12-01 20:16
Re: Active Topics list... (13 replies, posted in PunBB 1.3 additions)
Don't mean to be a bug or anything, but how do I use that bit of script? brd-main seems to be part of functions.php and I don't know if I should be directly editing that stuff...
10 2008-12-01 03:45
Re: Active Topics list... (13 replies, posted in PunBB 1.3 additions)
I'm interested in this as well. My forum is intended to be an off-shoot of another website that heavily relies on the "active topics" list (which only shows the last 5 topics with a post), and this plus a "topic subject in last post on index page" are the two extensions I'm really banking on to get this thing working nice.
Only problem is, the code is so cryptic and complicated that my procedural understanding of PHP is nowheres near able to figure that complicated mess out. All I can really do is wait.
11 2008-11-30 11:15
Re: [Extension release] Last post subject on index (51 replies, posted in PunBB 1.3 extensions)
Bump...
Quite an important extension IMO... an absolute staple in low-traffic or new forums that need to grab people's interest right off the bat.
Is there a way to make this work properly in 1.3?
edit: Ugh!! I'm trying to make it work, but everything seems to have changed between the "1.3" that this extension was designed for, and the "1.3" that actually made it out the door... it's so frustrating not having, really, any development tools to use with PunBB, like figuring out where data is coming from or going to, or how the extension and hook system works... or really anything at all... I keep having to uninstall and reinstall the extension to check how my changes work, and add "die(print_r($GLOBALS))" to the beginning of the installation script to figure out what the heck the variable names changed to... and then I find that the entire way the index page is generated has changed as well! *sigh*
It's worth it though. This is an absolutely essential extension that IMO should have been part of PunBB to begin with...
12 2008-11-29 04:13
Re: Default 1.3 theme (52 replies, posted in PunBB 1.3 additions)
You know, I just registered here to express my support for "the current one we're working on" - http://punbb.informer.com/trac/attachme … /5/120.png . It's much easier on the eyes, and more visually organized, than the comparatively jumbled and square design that PunBB currently is (even 1.3, which I'm using on my forum).
More images are much needed. Lightweight images, of course, and only a few of them, but images none the less. That current screenshot looks great, IMO.
All in all, we REALLY need more styles no matter WHAT they are. I'm a web developer but I work in good old fashioned HTML, not this XHTML+CSS+Javascript, etc., crap... I make some sweet standards-compliant websites, but the jumbled mess of incomprehensible CSS-styled <div> code is totally foreign to me. So in my PunBB forum, I have to rely on finding a style similar to what I want the forum to look like, then tweak pieces here and there. Building it from scratch is so far out of my scope!
And I think that work-in-progress one is just what I'm looking for. Will it be made available via the extensions system or will I have to keep an eye out here for it?
edit: Although the most notable image that appeared in the new style is just a forum logo... that alone is one option that's sorely missing from PunBB styles.