News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SMF Post Prefix

Started by Diego Andrés, May 11, 2015, 10:37:35 PM

Previous topic - Next topic

Diego Andrés

Quote from: Steve on April 13, 2023, 08:35:53 AMIn Admin → Topic Prefixes, how difficult would it be to have the sort order changed to the name column by default instead of the modify column?

Sources/PostPrefix/Admin/Manage.php
'default_sort_col' => 'modify', Change to 'default_sort_col' => 'item_name',
Not sure if it will be the right order, might need to invert these
'sort' =>  [
'default' => 'prefix_name',
'reverse' => 'prefix_name DESC',
],



Quote from: DeadMan... on April 13, 2023, 08:56:36 AMNot quite sure how to do that.
I'm still not familiar with the SSI.

SSI.php
Code (Search) Select
COALESCE(lt.id_msg, lmr.id_msg, 0) >= ml.id_msg_modified AS is_read,
COALESCE(lt.id_msg, lmr.id_msg, -1) + 1 AS new_from') . ', SUBSTRING(ml.body, 1, 384) AS body, ml.smileys_enabled, ml.icon
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
Code (Replace) Select
COALESCE(mem.real_name, ml.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
COALESCE(lt.id_msg, lmr.id_msg, 0) >= ml.id_msg_modified AS is_read,
COALESCE(lt.id_msg, lmr.id_msg, -1) + 1 AS new_from') . ', SUBSTRING(ml.body, 1, 384) AS body, ml.smileys_enabled, ml.icon,
t.id_prefix, pp.id AS prefix_id, pp.name AS prefix_name, pp.status AS prefix_status, pp.color AS prefix_color, pp.bgcolor AS prefix_bgcolor, pp.invert_color AS prefix_invert_color, pp.icon_class AS prefix_icon_class
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}postprefixes AS pp ON (t.id_prefix = pp.id)

Code (Search) Select
'subject' => $row['subject'],
'replies' => $row['num_replies'],
Code (Replace) Select
'subject' => PostPrefix::format($row) . $row['subject'],
'replies' => $row['num_replies'],

Not sure if it will work, didn't test it.
Also you'll probably or likely need to include Sources/PostPrefix/PostPrefix.php?

function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')
{
global $settings, $scripturl, $txt, $user_info;
global $modSettings, $smcFunc, $context;

require_once($sourcedir . '/PostPrefix/PostPrefix.php');

SMF Tricks - Free & Premium Responsive Themes for SMF.

DeadMan...

#541
Didn't work. Just gave me a 500 page.
Also, had error on the $sourcedir as not valid, so changed that and same result, just no error
, @Diego Andrés.

However, this part gives issue with the blocks, causing some things to not load, like rest of recent topics block and everything after.
'subject' => PostPrefix::format($row) . $row['subject'],
Fixed the issue, but they still don't show in that special recent topics block I am using.

global $scripturl, $context, $modSettings, $settings, $txt;
$context['TPortal']['recentboxnum'] = '25';

if(isset($modSettings['recycle_board']))
$bb = $modSettings['recycle_board'];

$what = ssi_recentTopics($context['TPortal']['recentboxnum'], NULL, NULL, 'array');
$counter=1;
$cmax = count($what);

echo '
<div style="width: 100%; overflow: auto; height: 30ex;">';
$member_ids = array();
foreach($what as $wi => $w)
{
$member_ids[] = $w['poster']['id'];
}

if(!empty($member_ids))
$avatars = progetAvatars($member_ids);
else
$avatars = array();


foreach($what as $w)
{
echo '<span class="tpavatar"><a href="' . $scripturl. '?action=profile;u=' . $w['poster']['id'] . '">' , empty($avatars[$w['poster']['id']]) ? '<img src="' . $settings['tp_images_url'] . '/TPguest.png" alt="" />' : $avatars[$w['poster']['id']] , '</a></span>
<div class="smalltext"><a href="'.$w['href'].'">' . $w['subject'] . '</a></div>
<div class="smalltext">', $txt['by'], ' <b>', $w['poster']['link'], '</b></div>
<div class="smalltext">';
if(!$w['new'])
{
if (!TP_SMF21)
echo '<a href="'.$w['href'].'"><img src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
else
echo '<a href="'.$w['href'].'" id="newicon" class="new_posts" >' . $txt['new'] . '</a> ';
}
echo '['.$w['time'].']
</div>';

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div>';
I tell it how I see it... Don't like it? Hit Alt+F4!

Arantor

You'd need to add $sourcedir to the list of globals.

DeadMan...

I did, @Arantor.
However, it doesn't appear to let me do the one edit I posted. It causes the blocks to not load. Starting with the recent topics block I posted.
I tell it how I see it... Don't like it? Hit Alt+F4!

Diego Andrés

Do you get any errors or info?
If everything is breaking after the block, then the error might be hiding around that area. I can't test it at the moment.

SMF Tricks - Free & Premium Responsive Themes for SMF.

DeadMan...

Quote from: Diego Andrés on April 13, 2023, 06:03:10 PMDo you get any errors or info?
If everything is breaking after the block, then the error might be hiding around that area. I can't test it at the moment.

That's the odd thing. Even after removing and getting the blocks back, there's no errors in the log.
I tell it how I see it... Don't like it? Hit Alt+F4!

Steve

Side note: Thanks Diego!

Back to @DeadMan...'s problem.
DO NOT pm me for support!

eliney

By chance, does anyone here have a version prior to v3.0 of this mod that they can share with me? I am looking for it since it is the only version that my forum supports smf 2.0.19 help please :'(  :'(

mickjav

In next version would it be possible to add feature(s)

  • if you add a new board at the moment you have to add the board to each existing prefix could there be a feature to add existing prefixes to the new board?
  • same for member groups

Mick

Diego Andrés

It's been 'logged' for a while.
It requires a good amount of work, or I don't know if it's even possible with hooks only.

I would need to work on it, but it's not a priority right now for me, hopefully in the future.

SMF Tricks - Free & Premium Responsive Themes for SMF.

mickjav

Quote from: Diego Andrés on May 23, 2023, 08:29:42 PMIt's been 'logged' for a while.
It requires a good amount of work, or I don't know if it's even possible with hooks only.

I would need to work on it, but it's not a priority right now for me, hopefully in the future.

As it's an admin only thing, it makes it easer.

I think I have a ways to make this work, all you would need to do is add a page to your admin or additional options to current admin page plus add the functions, lol.

I won't have a chance today, but if my misses still love me tomorrow, if not it'll be next week lol, I'll look at altering a function I have for doing something like this.

Feel free to use it or alter as needed.

All the best mick

Diego Andrés

4.3.0 - 27 May 2023
  • New Feature Select prefixes for a group when editing a group.
  • New Feature Select prefixes for a board when editing a board.
  • Improvement Improved settings HTML markup.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Shades.

Quote from: Shades. on October 28, 2022, 12:58:14 PM
Quote from: Diego Andrés on October 11, 2022, 10:48:19 AMThis mod uses hooks, so you'd have to manually add the column into the group by for the other mod.

It occurs to me, that @vbgamer45 could include
$message_index_selects
 in the group by, to account for the selects added by hooks?
Can someone tell me where to add this? I tried adding it myself but got more errors cause I don't have a clue what I'm doing! :laugh:  O:)  :P
Quote from: Diego Andrés on October 28, 2022, 08:23:27 PMI think @vbgamer45 already did something similar in the latest update of his mod  8)
Yeah he did but I was still getting errors so Since you updated your mod I decided to tinker with it again and I finally figured out how to add the columns myself and it was more than just the one.

On line 393 of MessageIndex.php I changed:
        GROUP BY t.id_topic, big.id_attach, thn.id_attach, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, ' . ($user_info['is_guest'] ? '' : ' lt.id_msg,lmr.id_msg, ' ) . '  t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time,
        t.id_redirect_topic, ml.id_msg_modified, ml.subject, ml.icon, ml.body, ml.poster_name, ml.id_member, meml.real_name, t.id_first_msg, mf.poster_time, mf.subject, mf.icon, mf.poster_name, mf.id_member, memf.real_name, ml.smileys_enabled,
        mf.smileys_enabled, big.filename, big.width, big.height, thn.filename, thn.width, thn.height, mf.body, t.id_board
' . (!empty($settings['avatars_on_indexes']) ? ',meml.avatar, meml.email_address, memf.avatar, af.id_attach, al.id_attach, af.attachment_type, al.attachment_type, al.filename, af.filename' : '') . '
            ORDER BY is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC'),
        $message_index_parameters
    );

To:
        GROUP BY t.id_prefix, pp.id, pp.name, pp.status, pp.color, pp.bgcolor, pp.invert_color, pp.icon_class, t.id_topic, big.id_attach, thn.id_attach, t.num_replies, t.locked, t.num_views, t.is_sticky, t.id_poll, t.id_previous_board, ' . ($user_info['is_guest'] ? '' : ' lt.id_msg,lmr.id_msg, ' ) . '  t.id_last_msg, t.approved, t.unapproved_posts, ml.poster_time,
        t.id_redirect_topic, ml.id_msg_modified, ml.subject, ml.icon, ml.body, ml.poster_name, ml.id_member, meml.real_name, t.id_first_msg, mf.poster_time, mf.subject, mf.icon, mf.poster_name, mf.id_member, memf.real_name, ml.smileys_enabled,
        mf.smileys_enabled, big.filename, big.width, big.height, thn.filename, thn.width, thn.height, mf.body, t.id_board
' . (!empty($settings['avatars_on_indexes']) ? ',meml.avatar, meml.email_address, memf.avatar, af.id_attach, al.id_attach, af.attachment_type, al.attachment_type, al.filename, af.filename' : '') . '
            ORDER BY is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC'),
        $message_index_parameters
    );

I had to add this to the beginning of the group by and seems to work perfect now with the other mod:
t.id_prefix, pp.id, pp.name, pp.status, pp.color, pp.bgcolor, pp.invert_color, pp.icon_class,
ShadesWeb.com - Custom Logos - My Themes on SMF | My Themes on ShadesWeb
https://shadesweb.com

BikerHound.com - Sniffing out the road ahead
https://bikerhound.com

Dream as if you'll live forever; Live as if you'll die today. - James Dean

Darknico

Quote from: Diego Andrés on May 27, 2023, 09:38:44 PM4.3.0 - 27 May 2023
  • New Feature Select prefixes for a group when editing a group.
  • New Feature Select prefixes for a board when editing a board.
  • Improvement Improved settings HTML markup.

Added italian translation update

P.S. in crowdin, you can uoload this file?
I have no permits... thanks :)
Italian SMF - Supporto Italiano per la board SMF - Ci trovate tutti li!! :)


Diego Andrés

Thanks, will update languages soon.  ;D

SMF Tricks - Free & Premium Responsive Themes for SMF.

Diego Andrés

4.3.1 - 02 June 2023
  • Translation Italian translation provided by Darknico
  • Translation Updated translations.

SMF Tricks - Free & Premium Responsive Themes for SMF.

sbartelski

Diego,
I like the look of your mod, but as an SMF noob I am not sure how to install it. I looked up 'hooks' in the SMF documentation and found it quite confusing. Do you, or someone else, have a step by step guide on installing a 'hooks' mod like yours?

TIA
Stefan
Stefan Bartelski
Webmaster for the Cadillac LaSalle Discussion forums

TwitchisMental

#557
Quote from: sbartelski on June 29, 2023, 12:54:15 PMDiego,
I like the look of your mod, but as an SMF noob I am not sure how to install it. I looked up 'hooks' in the SMF documentation and found it quite confusing. Do you, or someone else, have a step by step guide on installing a 'hooks' mod like yours?

TIA
Stefan
You do not need to worry about the "Hooks".

You are looking for how to install a mod package.

See more here - https://wiki.simplemachines.org/smf/SMF2.1:Package_manager

jafl

Hello:
I am getting an error on this line, could you help me?

<a class="button button_strip_' . $key . (!empty($value['active']) ? ' active' : '') . (isset($value['class']) ? ' ' . $value['class'] : '') . '" ' . (!empty($value['url']) ? 'href="' . $value['url'] . '"' : '') . ' ' . (isset($value['custom']) ? ' ' . $value['custom'] : '') . '>'.(!empty($value['icon']) ? '<span class="main_icons '.$value['icon'].'"></span>' : '').'' . $txt[$value['text']] . '</a>';
Thank you very much and sorry for my english

Diego Andrés

Quote from: jafl on July 03, 2023, 01:32:20 AMI am getting an error on this line, could you help me?

Hola, esa línea no tiene que nada ver con este MOD o no tiene suficiente contexto.
Lo mejor es que abras un tema de soporte y expliques qué problema tienes, ya sea en inglés o español.

Saludos!

SMF Tricks - Free & Premium Responsive Themes for SMF.

Advertisement: