News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Alerts - Icon HTML formatting different for Moved Topic

Started by Julius_2000, May 08, 2023, 06:43:39 AM

Previous topic - Next topic

Julius_2000

Hi,
I noticed that in the top menu, the alert icon for Moved Topic was missing (displaying a placeholder) in our theme. We use fontawesome for our theme and all other icons like sticky/ locked etc. work just fine.

You cannot view this attachment. You cannot view this attachment.

So I had a closer look at the HTML of the default SMF theme and I noticed that the formatting for Moved Topic appears to be different from other icons.

While all other icons are wrapped in a div that uses the class main_icons followed by the action that was executed, for instance main_icons sticky
You cannot view this attachment.

Moved Topics simply use an img reference which is pointed to our custom theme directory (where there is no post folder in "images") instead of "default".
You cannot view this attachment.

I had a look at Profile.template.php but I couldn't figure out what triggers the main_icons + "name"

All it says is $details['icon'] in the unread_notify_image section:
    if (empty($context['unread_alerts']))
        template_alerts_all_read();

    else
    {
        foreach ($context['unread_alerts'] as $id_alert => $details)
        {
            echo '
            <', !$details['show_links'] ? 'a href="' . $scripturl . '?action=profile;area=showalerts;alert=' . $id_alert . '" onclick="this.classList.add(\'alert_read\')"' : 'div', ' class="unread_notify">
                <div class="unread_notify_image">
                    ', empty($details['sender']['avatar']['image']) ? '' : $details['sender']['avatar']['image'] . '
                    ', $details['icon'], '
                </div>
                <div class="details">
                    <span class="alert_text">', $details['text'], '</span> <br> <span class="alert_time">', $details['time'], '</span>
                </div>
            </', !$details['show_links'] ? 'a' : 'div', '>';
        }
    }

Is this a bug? What could I do/ where would I have to look to get a "main_icons moved" output for the class?


Diego Andrés

It's located inside Profile-View.php
function set_alert_icon($alert)

But realistically, you'd want to fix this issue in your theme by restoring/fixing the image or the css for the icon.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Julius_2000

Quote from: Diego Andrés on May 17, 2023, 07:15:58 PMIt's located inside Profile-View.php
function set_alert_icon($alert)

Thanks! It does look like it was coded differently

case 'move':
  $src = $settings['images_url'] . '/post/moved.png';
  break;

While all other cases are structured this way, using the "main_icons + action" property for its classes
case 'remove':
  $class = 'main_icons delete';
  break;

Does any developer know the reason for that? Was the "moved" image not part of the original icon sprite which main_icons uses? But then again, the icon seems to be used in that main_icon fashion in a board's icon legend.

Diego Andrés

Quote from: Julius_2000 on May 17, 2023, 07:49:23 PMDoes any developer know the reason for that? Was the "moved" image not part of the icon sprite which main_icons uses? But then again, the icon seems to be used in that main_icon fashion in the icon legend on a board.
Possibly.

Additionally, this is an inconsistency I tried to fix. As you can see, the legend is using the icon from the icons sprite, main_icons.move because it was used in other places.
We should definitely correct this and fully drop or embrace the post icon instead of the sprite or vice versa.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Julius_2000

Alright! Just edited it to follow the main_icons format and it worked.

Advertisement: