1 (edited by Dexus 2005-03-31 19:09)

Topic: [minimod] Last topic name in forum list.

in punbb 1.2.4

replace line 41 of index.php

// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id 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 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

with

// Print the categories and forums
$result = $db->query('
SELECT c.id AS cid, c.cat_name, f.id AS fid,
f.forum_name, f.forum_desc, f.redirect_url,
f.moderators, f.num_topics, f.num_posts,
f.last_post, f.last_post_id, f.last_poster,
t.subject
FROM '.$db->prefix.'categories AS c
INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id
INNER JOIN '.$db->prefix.'posts AS p ON p.id=f.last_post_id
INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id
LEFT JOIN 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
ORDER BY c.disp_position, c.id, f.disp_position
', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

replace line 109 index.php

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';

with

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
        $last_post = format_time($cur_forum['last_post']).' '.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'<span class="byuser"> in <a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.pun_htmlspecialchars($cur_forum['subject']).'</a></span>';

2 (edited by Dexus 2005-03-31 19:32)

Re: [minimod] Last topic name in forum list.

And if you need to use multilanguage support:
after line 69 lang/English/common.php

'by'=>'by',    // as in last post by someuser

insert

'in'=>'in',    // as in last post in some topic

and second replace code fragment from above must be:

    // If there is a last_post/last_poster.
    if ($cur_forum['last_post'] != '')
$last_post = format_time($cur_forum['last_post']).' '.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'<span class="byuser">'.$lang_common['in'].' <a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.pun_htmlspecialchars($cur_forum['subject']).'</a></span>';

Re: [minimod] Last topic name in forum list.

I got this DB error

"Error: Unable to fetch category/forum list."

Re: [minimod] Last topic name in forum list.

nvm I got it

// Print the categories and forums
$result = $db->query('
SELECT c.id AS cid, c.cat_name, f.id AS fid,
f.forum_name, f.forum_desc, f.redirect_url,
f.moderators, f.num_topics, f.num_posts,
f.last_post, f.last_post_id, f.last_poster,
t.subject
FROM '.$db->prefix.'categories AS c
INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id
INNER JOIN '.$db->prefix.'posts AS p ON p.id=f.last_post_id
INNER JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id
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
ORDER BY c.disp_position, c.id, f.disp_position
', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

the part LEFT JOIN forum_perms did not have '.$db->prefix.' that up there does ^_^

Re: [minimod] Last topic name in forum list.

now another thing

it messes with me categories. It does not show the last category and when I make new ones they don't show.

6 (edited by Dexus 2005-04-01 03:56)

Re: [minimod] Last topic name in forum list.

SELECT c.id AS cid, c.cat_name, f.id AS fid,
f.forum_name, f.forum_desc, f.redirect_url,
f.moderators, f.num_topics, f.num_posts,
f.last_post, f.last_post_id, f.last_poster,
t.subject
FROM '.$db->prefix.'categories AS c
INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id
LEFT JOIN '.$db->prefix.'posts AS p ON p.id=f.last_post_id
LEFT JOIN '.$db->prefix.'topics AS t ON t.id=p.topic_id
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
ORDER BY c.disp_position, c.id, f.disp_position

it makes little SQL perfomance decrease.
other way to make this - to add "subject" column to "forums" table, and fix some inserts/updates in include/functions.php

Re: [minimod] Last topic name in forum list.

I'll work on it to where it's not so hacked smile

8 (edited by Dexus 2005-04-01 07:10)

Re: [minimod] Last topic name in forum list.

I've finished with actual install_mod.php and readme.txt with instructions.
take it from here

Re: [minimod] Last topic name in forum list.

still have the same problem.

10

Re: [minimod] Last topic name in forum list.

What exactly??

11 (edited by shinko_metsuo 2005-04-02 16:40)

Re: [minimod] Last topic name in forum list.

nvm it was my fault ^_^;; thanks for the help

12

Re: [minimod] Last topic name in forum list.

Glad to hear that smile
I don't cnow why this "last subject" feature isn't integrated into punbb by default...
Maybe Rickard will argue. Maybe server will be overloaded? I don't know, but I don't think so.

Re: [minimod] Last topic name in forum list.

yeah its a great mod.

Its really great for a help forum(like this) so the user knows what is being asked without having to click around.

14

Re: [minimod] Last topic name in forum list.

"Show your posts" from index page (in the bottom of page) will show you messages, related to you smile
"Show recent posts" is also good.

15 (edited by Dexus 2005-04-03 13:31)

Re: [minimod] Last topic name in forum list.

I've updated "install_mod.php" to update_forum after installing.. To avoid null subject names.
You can run this code in php. I haven't found built-in forums update in administration
make .php file with this code, and run it.

<?php
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';


    $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Unable to fetch forum info.', __FILE__, __LINE__, $db->error());

    while ($row = $db->fetch_row($result))
        update_forum($row[0]);

Re: [minimod] Last topic name in forum list.

2Dexus
? ?????? ?? ?? ??????? ???, ??? ??? ??????? ??????, ???????????? ?????? ????? ????????, ? ????????? ??? ????????? ???? (? ???? title)?

17

Re: [minimod] Last topic name in forum list.

Austral, ñäåëàé. Ýòî íåñëîæíî.
Ïîêà òàêîé íåîáõîäèìîñòè ó ìåíÿ íå áûëî. Â ñïèñêå ôîðóìîâ âñå ðàâíî íåñêîëüêî ñòðîê âëàçÿò áåç ïðîáëåì. È íàñòîëüêî äëèííûõ òåì íå áûâàåò. Ìàêñèìóì - 70 ñèìâîëîâ.

Re: [minimod] Last topic name in forum list.

2Dexus
ß òî çäåëàë óæå, íî åñëè ïîìíèøü, òî â ñòàðîé âåðñèè ýòîãî ïëàãèíà (êîòîðûé áûë åù¸ ïîä 1.1.4) òàêàÿ ôóíêöèÿ áûëà ïî óìîë÷àíèþ.

È åù¸, â ñòàíäàðòíûé äèçàéí ìîæåò è âëåçåò íåñêîëüêî ñòðîê áåç ïðîáëåì, íî åñëè äèç çàòî÷åí ïîä ñâîé òî è ðàçìåðû ÿ÷ååê íåìíîãî äðóãèå.

19 (edited by Ataxy 2005-04-14 15:21)

Re: [minimod] Last topic name in forum list.

ok i got a problem after instaling your mod ,it appears  over each category
Notice: Undefined index: in in /home/vhost/d-vault.peerforces.com/html/forum/forum.php on line 107
the forum.php is the same as the index.php i had to change the name to install the miniportal mod from connorhd

this is the line 107 its actualy one of the line you ask to change in the read me of your mod
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'<span class="byuser">'.$lang_common['in'].' <a href="viewtopic.php?id='.$cur_forum['last_tid'].'">'.pun_htmlspecialchars($cur_forum['last_subject']).'</a></span>';

EDIT
ok found my error i hadnt made the change to the common.php file int the lang folder ,so since i made it i do not have the error:
Notice: Undefined index: in in /home/vhost/d-vault.peerforces.com/html/forum/forum.php on line 107
but i get nothing instead i simply display nothing its just like it was before the mod

EDIT2

ok it did partially work now i get this at the end of the forum :
Yesterday 02:10:50 by ataxyin
but as you can see there is no space in between the "name" and the "in" and the subject does not appear after the "in"

EDIT3
ok the space between the "name" and the "in" was easy just had to change this part
]).'<span class="byuser">'.$lang_common['in'].
to this
]).'<span class="byuser"> '.$lang_common['in'].

but i still get nothing after the "in"

EDIT4
ok never mind again it was my fault i had not run the small php script you posted that was for the subject
thx again and nice mod

EDIT5
ok made some change to the code for some esthetic i changed this :
g_common['in'].'<a href="viewtopic.php?id='.$cur_forum
for this :
g_common['in'].'<br> <a href="viewtopic.php?id='.$cur_forum

wich puts the subject on a seperate line

and changed this :
'in'                    =>  'in',    // as in last post in some topic
for
'in'                    =>  'in:',    // as in last post in some topic

20

Re: [minimod] Last topic name in forum list.

Austral, ÿ íå âèäåë íèêàêèõ ïðåäûäóùèõ ìîäîâ, ÿ åãî ïî íóæäå ñâàðãàíèë ïî áûñòðîìó.. è ïðîñòî ðåøèë ïîäåëèòüñÿ (ñêîðåå âñåãî íåóêëþæå)... Òû æå íàâåðíî ïîíèìàåøü, ÷òî íà íå ñòàíäàðòíûå äèçàéíû ÿ ðàñ÷èòûâàòü íå áóäó, ê òîìó æå äëèíó ñîîáùåíèÿ.. ÷åðåç îïöèè çàäàâàòü? smile .. ó êîãî ðóêè âñòàâëåíû íóæíûì ìåñòîì, òîò äîâåäåò äî óìà... íà òàêèõ, íàâåðíî, è ðàñ÷èòàíî...

Ataxy, smile you may take your chance to release your own, more stable vesion, with much more detailed instructions..

21

Re: [minimod] Last topic name in forum list.

oh no sincerly i made only small change to your code so the mod is still yours thx for your work

22

Re: [minimod] Last topic name in forum list.

Ataxy, it's not actually mine.. because idea is common.. realisation touches small part of code...
I don't think i have any ownership on this code smile

23 (edited by Ataxy 2005-04-14 17:08)

Re: [minimod] Last topic name in forum list.

ok then i am proud to announce that i have made this partnership mod better lol ,still thx for your part of the work smile

Re: [minimod] Last topic name in forum list.

Any way to get this to work with version 1.2.5?

Re: [minimod] Last topic name in forum list.

This code

if ($cur_forum['last_post'] != '')
        $last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> '.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'<span class="byuser">'.$lang_common['in'].' <a href="viewtopic.php?id='.$cur_forum['last_tid'].'">'.pun_htmlspecialchars($cur_forum['last_subject']).'</a></span>';

shows the display as


Time by User
in Subject


How can I get it to show

Subject
Time
by User