Topic: [Extension] Last post subject on index

Title: Last Post Subject on Forum Index / Linkify poster links v1.0
Quick Description: This will add the subject of the last post under the last post column on the index page and will add a link to the persons profile. Now can be tailored for your needs via admin menu.

Notes: Username linkify default is off. This is because the username linkify puts slightly more strain on the database (not much) so felt it best to give the option to turn this off/on as required.

Download: subject_index.zip

Live Demo: FluxDemo.org - Was installed at time of posting this. tongue

Image examples:
Admin menu settings
http://www.stevenbullen.com/fluxbb/extensions/subject_index/si_admin_view.jpg

Example...
index.php - before
http://www.stevenbullen.com/fluxbb/extensions/subject_index/si_index_before.jpg

index.php - after
http://www.stevenbullen.com/fluxbb/extensions/subject_index/si_index_after.jpg



viewforum.php - before
http://www.stevenbullen.com/fluxbb/extensions/subject_index/si_viewforum_before.jpg

viewforum.php - after
http://www.stevenbullen.com/fluxbb/extensions/subject_index/si_viewforum_after.jpg

Feedback: Any recommendations will be thought about. tongue

Last edited by StevenBullen (2008-05-16 16:42:03)

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

Thank you for this Steven. Great addition. smile

Re: [Extension] Last post subject on index

For moved topics, it is showing "Topics moved by" instead of "Topics moved".

Don't linkify username if it is a Guest.

Request: Option to display the entire subject and let it flow to the next line if long.

Thank you.

Last edited by quy (2008-05-15 06:17:28)

Re: [Extension] Last post subject on index

qubertman wrote:

For moved topics, it is showing "Topics moved by" instead of "Topics moved".

Don't linkify username if it is a Guest.

Request: Option to display the entire subject and let it flow to the next line if long.

Thank you.

as always nice detection ... are you a detective or some thing like that

Sports2All: Watch Online all the Sports (Wrestling, Football, Cricket & All other Sports)

Re: [Extension] Last post subject on index

qubertman wrote:

For moved topics, it is showing "Topics moved by" instead of "Topics moved".

Don't linkify username if it is a Guest.

Fixed! Fixed!

qubertman wrote:

Request: Option to display the entire subject and let it flow to the next line if long.

Not so sure on this one. Will have a think about it.

Last edited by StevenBullen (2008-05-15 06:42:14)

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

If the test is truncated on the index then it does not validate.

line 90 column 156 - Warning: unescaped & or unknown entity "&#8230"

Shedrock

Re: [Extension] Last post subject on index

Thanks for this, a great extension! Keep it up smile

Musicians Forum
The Community for all musicians and fans.

Re: [Extension] Last post subject on index

dang u beat me to it tongue

Re: [Extension] Last post subject on index

What about the validation issue?

Re: [Extension] Last post subject on index

@shedrock
Will take a look later. wink

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

ok, thanks. big_smile

Re: [Extension] Last post subject on index

shedrock wrote:

If the test is truncated on the index then it does not validate.

line 90 column 156 - Warning: unescaped & or unknown entity "&#8230"

Shedrock

Fixed! smile

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

Thanks Steven,

It works like a charm.

Shedrock

Re: [Extension] Last post subject on index

v1.3 released
No fixes! Just code clean up.

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

StevenBullen wrote:

v1.3 released
No fixes! Just code clean up.

Have you changed download link?

Musicians Forum
The Community for all musicians and fans.

Re: [Extension] Last post subject on index

Tommy wrote:
StevenBullen wrote:

v1.3 released
No fixes! Just code clean up.

Have you changed download link?

Yep. tongue

Blog - Follow Me and FluxBB on Twitter

Re: [Extension] Last post subject on index

Bug/Something Missing - When you click the topic link from index and view it, it doesn't mark it as read.

Musicians Forum
The Community for all musicians and fans.

Re: [Extension] Last post subject on index

manifest.xml line 135, missing lang directory for default language

Sorry for my English ;p

Re: [Extension] Last post subject on index

Tommy wrote:

Bug/Something Missing - When you click the topic link from index and view it, it doesn't mark it as read.

This is Flux code not mine. I dont change anything on viewtopic.php for it to change the way it marks as read.

daris wrote:

manifest.xml line 135, missing lang directory for default language

Fixed. Link has been updated with fix.

Blog - Follow Me and FluxBB on Twitter

20

Re: [Extension] Last post subject on index

Anyone know what happened with StevenBullen' s domain ?

I can' t download this extention.

if anyone can help me with getting this just let me know

Thx

Lum

Re: [Extension] Last post subject on index

1) create subject_index directory inside extensions dir
2) create manifest.xml file inside subject_index

<?xml version="1.0" encoding="UTF-8"?>
 
<extension engine="1.0">
    <id>subject_index</id>
    <title>Last Post Subject on Forum Index / Linkify poster links</title>
    <version>1.3</version>
    <description>This will add the subject of the last post under the last post column on the index page and will add a link to the persons profile. Now can be tailored for your needs via admin menu.</description>
    <author>StevenBullen</author>
    <minversion>1.3 Beta</minversion>
    <maxtestedon>1.3 Beta</maxtestedon>
    
    <install>
        <![CDATA[
            switch($forum_db_type)
            {
                case 'mysql':
                case 'mysqli':
                    $forum_db->query('ALTER TABLE '.$forum_db->prefix.'topics ADD INDEX '.$forum_db->prefix.'topics_last_post_id_idx(last_post_id)');
                break;
                case 'default':
                    $forum_db->query('CREATE INDEX '.$forum_db->prefix.'topics_last_post_id_idx ON '.$forum_db->prefix.'topics(last_post_id)');
                break;
            }
            
            $forum_db->query('INSERT INTO '.$forum_db->prefix.'config (`conf_name`, `conf_value`) VALUES (\'o_si_show_topic\', 1)');
            $forum_db->query('INSERT INTO '.$forum_db->prefix.'config (`conf_name`, `conf_value`) VALUES (\'o_si_show_date\', 1)');
            $forum_db->query('INSERT INTO '.$forum_db->prefix.'config (`conf_name`, `conf_value`) VALUES (\'o_si_link_profile\', 0)');
            $forum_db->query('INSERT INTO '.$forum_db->prefix.'config (`conf_name`, `conf_value`) VALUES (\'o_si_topic_length\', 35)');

            // Regenerate the config cache
            require_once FORUM_ROOT.'include/cache.php';
            generate_config_cache();
        ]]>
    </install>
    <uninstall>
        <![CDATA[
            switch($forum_db_type)
            {
                case 'mysql':
                case 'mysqli':
                    $forum_db->query('ALTER TABLE '.$forum_db->prefix.'topics DROP INDEX '.$forum_db->prefix.'topics_last_post_id_idx');
                break;
                case 'default':
                    $forum_db->query('DROP INDEX '.$forum_db->prefix.'topics_last_post_id_idx');
                break;
            }
            
            $forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name=\'o_si_show_topic\'') or error(__FILE__, __LINE__);
            $forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name=\'o_si_show_date\'') or error(__FILE__, __LINE__);
            $forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name=\'o_si_link_profile\'') or error(__FILE__, __LINE__);
            $forum_db->query('DELETE FROM '.$forum_db->prefix.'config WHERE conf_name=\'o_si_topic_length\'') or error(__FILE__, __LINE__);
            
            // Regenerate the config cache
            require_once FORUM_ROOT.'include/cache.php';
            generate_config_cache();
        ]]>
    </uninstall>
 
    <hooks>
        <hook id="in_qr_get_cats_and_forums"><![CDATA[
            if ($forum_config['o_si_show_topic'] == '1')
            {
                $query['SELECT'] .= ', ext_si_t.subject';
                $query['JOINS'][] = array(
                    'LEFT JOIN'    => 'topics AS ext_si_t',
                    'ON'        => 'ext_si_t.last_post_id=f.last_post_id'
                );
            }

            if ($forum_config['o_si_link_profile'] == '1')
            {
                $query['SELECT'] .= ', ext_si_p.poster_id';
                $query['JOINS'][] = array(
                    'LEFT JOIN'    => 'posts AS ext_si_p',
                    'ON'        => 'ext_si_p.id=f.last_post_id'
                );
            }
        ]]></hook>
        <hook id="vf_qr_get_topics"><![CDATA[
            if ($forum_config['o_si_link_profile'] == '1')
            {
                $query['SELECT'] .= ', ext_si_p.poster_id AS last_poster_id';
                $query['JOINS'][] = array(
                    'LEFT JOIN'    => 'posts AS ext_si_p',
                    'ON'        => 't.last_post_id=ext_si_p.id'
                );
            }
        ]]></hook>
        <hook id="in_row_pre_display"><![CDATA[
            if ($cur_forum['last_post'] != '')
            {
                $ext_si = array();
                
                if ($forum_config['o_si_show_topic'] == '1')
                {
                    $ext_si['subject'] = $cur_forum['subject'];
                    
                    if ($forum_config['o_censoring'] == '1')
                        $ext_si['subject'] = censor_words($ext_si['subject']);

                    if(strlen($ext_si['subject']) > $forum_config['o_si_topic_length']) {
                        $ext_si['subject_short'] = str_replace('"', "''", $ext_si['subject']);
                        $ext_si['subject'] = substr($ext_si['subject'], 0, $forum_config['o_si_topic_length']).'&#8230;';
                    }

                    $ext_si['subject_title'] = (!empty($ext_si['subject_short'])) ? ' title="'.$ext_si['subject_short'].'"' : '';

                    if ($forum_config['o_si_show_date'] == '1')
                        $ext_si['posted'] = format_time($cur_forum['last_post']);
                    
                    $forum_page['item_last_post']['post'] = '<span><a href="'.forum_link($forum_url['post'], $cur_forum['last_post_id']).'"'.$ext_si['subject_title'].'>'.$ext_si['subject'].'</a></span>';
                }
                
                if ($forum_config['o_si_link_profile'] == '1' && $forum_user['g_view_users'] == '1' && $cur_forum['poster_id'] > 1)
                    $ext_si['user'] = '<a href="'.forum_link($forum_url['user'], $cur_forum['poster_id']).'">'.htmlspecialchars($cur_forum['last_poster']).'</a>';
                else
                    $ext_si['user'] = htmlspecialchars($cur_forum['last_poster']);
            
                $forum_page['item_last_post']['poster'] = '<span class="byuser">'.$ext_si['posted'].' '.sprintf($lang_common['By user'], $ext_si['user']).'</span>';
            }
        ]]></hook>        
        <hook id="vf_row_pre_display"><![CDATA[
            $ext_si = array();
            
            if ($forum_config['o_si_link_profile'] == '1' && $forum_user['g_view_users'] == '1' && $cur_topic['moved_to'] == null && $cur_topic['last_poster_id'] > 1)
            {
                $ext_si['user_last'] = '<a href="'.forum_link($forum_url['user'], $cur_topic['last_poster_id']).'">'.htmlspecialchars($cur_topic['last_poster']).'</a>';
                $forum_page['item_last_post']['last_poster'] = '<span class="byuser">'.sprintf($lang_common['By user'], $ext_si['user_last']).'</span>';
            }
        ]]></hook>
        <hook id="aop_start"><![CDATA[
            if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'.php'))
                require $ext_info['path'].'/lang/'.$forum_user['language'].'.php';
            else
                require $ext_info['path'].'/English.php';
        ]]></hook>
        <hook id="aop_features_validation"><![CDATA[        
            if (!isset($form['si_show_topic']) || $form['si_show_topic'] != '1') $form['si_show_topic'] = '0';
            if (!isset($form['si_show_date']) || $form['si_show_date'] != '1') $form['si_show_date'] = '0';
            if (!isset($form['si_link_profile']) || $form['si_link_profile'] != '1') $form['si_link_profile'] = '0';
            $form['si_topic_length'] = intval($form['si_topic_length']);        
        ]]></hook>
        <hook id="aop_features_general_end"><![CDATA[
?>
                    <div class="radbox checkbox"><label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span class="fld-label"><?php echo $lang_subject_index['Username Links'] ?></span> <input type="checkbox" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[si_link_profile]" value="1"<?php if ($forum_config['o_si_link_profile'] == '1') echo ' checked="checked"' ?> /> <?php echo $lang_subject_index['Turn Link'] ?></label></div>
                    <div class="frm-fld text">
                        <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
                            <span class="fld-label"><?php echo $lang_subject_index['Subject Index'] ?></span><br />
                            <span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[si_topic_length]" size="3" maxlength="3" value="<?php echo $forum_config['o_si_topic_length'] ?>" /></span><br />
                            <span class="fld-extra"><?php echo $lang_subject_index['Subject Size'] ?></span>
                        </label>
                    </div>
                    <div class="radbox"><label for="fld<?php echo ++$forum_page['fld_count'] ?>"><input type="checkbox" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[si_show_topic]" value="1"<?php if ($forum_config['o_si_show_topic'] == '1') echo ' checked="checked"' ?> /> <?php echo $lang_subject_index['Show Topic'] ?></label></div>
                    <div class="radbox"><label for="fld<?php echo ++$forum_page['fld_count'] ?>"><input type="checkbox" id="fld<?php echo $forum_page['fld_count'] ?>" name="form[si_show_date]" value="1"<?php if ($forum_config['o_si_show_date'] == '1') echo ' checked="checked"' ?> /> <?php echo $lang_subject_index['Show Date'] ?></label></div>
<?php
        ]]></hook>
    </hooks>
</extension>

3) create lang directory inside subject_index directory
4) create file English.php inside lang dir

<?php
// Language file for Subject Index

$lang_subject_index = array(
    'Username Links'        =>    'Username Linkify',
    'Subject Index'            =>    'Last Post (Subject)',
    'Subject Size'            =>    'Maximum length of topic. Customize to fit your style.',
    'Show Topic'            =>    'Show Last Post Subject on Forum Index.',
    'Show Date'                =>    'Show Last Post Date on Forum Index.',
    'Turn Link'                =>    'Enable linkify on posters username. (For the index page and also viewforum page)'
);
?>

22

Re: [Extension] Last post subject on index

Thx

Unfortunatly I get the following error

Notice: Undefined variable: forum_db_type in /xxx/admin/extensions.php(171) : eval()'d code on line 5

Notice: Undefined variable: forum_db_type in /xxx/admin/extensions.php(171) : eval()'d code on line 6

Notice: Undefined variable: forum_db_type in /xxx/admin/extensions.php(171) : eval()'d code on line 9

I' m running svn 533 of the 1.3 version
Updated to svn 540 but same problem stil there

had a look at line 5,6,9 of the manifest.xml file but do not see any problems there. so does anyone know what the problem is or where I have to look ?

Lum

Last edited by Lum (2008-08-03 12:18:33)

Re: [Extension] Last post subject on index

Download is down, anyone have a mirror?

Re: [Extension] Last post subject on index

Mr Mister had post the file to create in the post above patrick

Re: [Extension] Last post subject on index

I believe the download link is down...