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']).'…';
}
$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)'
);
?>