Advertisement:

Author Topic: silly lightweight PM notification adjustment [2.0.15]  (Read 4626 times)

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 702
    • College Football Fan Site CFB51
silly lightweight PM notification adjustment [2.0.15]
« on: July 07, 2019, 03:59:40 AM »
as much as i like some of the alert systems out there both premium and freely available in the mod sets, i simply don't want to bog the page anymore than i have to... this is SO simple i don't know why i've not done it prior. 

in your sources/subs.php, find:
Code: [Select]
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . '[' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= '[ <strong">' . $context['user']['unread_messages'] . '</strong>]';


replace with:
Code: [Select]
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . '[' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' <span class="pmz-noty">' . $context['user']['unread_messages'] . '</span> ';

in your theme's CSS file, add something like this at the bottom; adjust as you see fit:
Code: [Select]
#button_pm .pmz-noty{background:red;border:1px solid #fff;border-radius:100%;padding:3px 6px;color:#fff;font-weight:700;text-align:center}


here is the product on my page in action.. you can tool the CSS however you want, but the point is it jumps out so users don't miss messages and it creates zero additional load (js) on a page....

« Last Edit: July 07, 2019, 07:11:07 AM by drewactual »

Online SychO

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 1,535
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #1 on: July 09, 2019, 08:08:48 AM »
Simple and effective :)
Take the initiative

Offline Shambles

  • SMF Hero
  • ******
  • Posts: 5,192
  • Gender: Male
    • i30 Owners Club
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #2 on: July 09, 2019, 08:31:43 AM »
It looks great on Crip's BlackBox theme

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,629
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #3 on: July 09, 2019, 08:46:04 AM »
Nice tip!
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • SMF Hero
  • *
  • Posts: 2,187
  • Gender: Male
    • Macedonian electronics forum
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #4 on: July 09, 2019, 06:41:53 PM »
Yeah, thanks for the tip ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,007
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #5 on: July 15, 2019, 12:22:33 PM »
simple and direct, as I like it :).


Regards!
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,808
  • Master of BBC Abuse
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #6 on: July 15, 2019, 07:09:06 PM »
Nice touch. I remember doing something similar years ago in a bit of custom theming, and I always rather liked the effect. From memory, I used relative positioning on the parent element and absolute on the span, to position it above the menu links as its own little pop-up. There are umpteen ways you can style the thing and most of them are pretty easy to arrange. :)

I'm surprised someone hasn't turned this into a mod before now. The Subs.php edit is really basic and unlikely to ever break anything.

Offline Diego Andrés

  • Customizer
  • SMF Hero
  • *
  • Posts: 3,357
  • Gender: Male
    • DiegoSetroc on GitHub
    • @bihgetter on Twitter
    • SMF Tricks - Free & Premium Themes
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #7 on: July 15, 2019, 08:01:58 PM »
Simple and useful.

Also as a detail, I believe it shouldn't be necessary to replace the <strong> tag since the only appearance of those in the menu is precisely for those numbers (PM's, reports and other stuff depending on a few mods available like DevCenter for errors log in Admin button). So could just play around with the strong tag along with the menu classes.

Regards :P

SMF Tricks - Free & Premium Responsive Themes for SMF.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 702
    • College Football Fan Site CFB51
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #8 on: July 15, 2019, 09:13:42 PM »
yeah, the 'strong' tag 'can' be manipulated for that div id (button_pm) and avoid the subs.php edit altogether, but.... it's not clean or valid, which means a browser can stop honoring it at any point or a browser may just ignore it as it is right now just to honor it the next time... it can certainly be left in the strong tag, but wrapping it in a class harms nothing yet allows whatever css to be applied that meets the need of the user- square, transparent, float or anchored.... it can even be given an absolute and/or fixed and a z-index above other elements an staying on the screen (upper right, let's say) just so you KNOW it is seen by the user...

i think the point is to just get it into a class where the user can manipulate it at will and with ease, and that is valid. 

i'm happy others can take this and use it- it is SO silly a little thing it should have been done a long time ago and addressed by many.  at least i should have done it on my own pages a long time ago... it's one of those things that easily fall off the radar, ya know?

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,808
  • Master of BBC Abuse
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #9 on: July 16, 2019, 12:26:35 AM »
There's nothing wrong with using the strong tag. It's perfectly valid HTML, and no browser is likely to stop recognising it in the foreseeable future. A class isn't strictly necessary, and the lack of one doesn't stop you styling the tag any way you like. Obviously you'd have to declare display: block; for some styling options, but that's fine.

By using descendants you could easily target the CSS to the PM button even if there were other strong tags floating around. Slightly less efficient in terms of CSS processing, but slightly more efficient in terms of HTML. For this example nobody is ever likely to notice the difference even if they are benchmarking nuts.

The strong tag isn't bound to bold text or to being an inline element. It's just meant to indicate text that should have attention paid to it, which is ideal for this use case. Within reason you can pretty much use it however you like without any browser or semantics nerd throwing a wobbly over it. So if someone wants to use the same idea without editing Subs.php there's nothing to stop them doing it.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 702
    • College Football Fan Site CFB51
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #10 on: July 16, 2019, 11:47:59 AM »
There's nothing wrong with using the strong tag. It's perfectly valid HTML, and no browser is likely to stop recognising it in the foreseeable future. A class isn't strictly necessary, and the lack of one doesn't stop you styling the tag any way you like. Obviously you'd have to declare display: block; for some styling options, but that's fine.

By using descendants you could easily target the CSS to the PM button even if there were other strong tags floating around. Slightly less efficient in terms of CSS processing, but slightly more efficient in terms of HTML. For this example nobody is ever likely to notice the difference even if they are benchmarking nuts.

The strong tag isn't bound to bold text or to being an inline element. It's just meant to indicate text that should have attention paid to it, which is ideal for this use case. Within reason you can pretty much use it however you like without any browser or semantics nerd throwing a wobbly over it. So if someone wants to use the same idea without editing Subs.php there's nothing to stop them doing it.

^that's good to know, and it eliminates the need to adjust subs.php altogether.  And... I'm NOT innocent of this- one of the examples i've relied on is for the post editor and post display specifically, and is styling br's... not something supported, but something every major browser has honored.   basically, i styled br's in post class div's to display in blocks and with a bottom margin of 1.2em.  same concept as styling a strong tag in the button_pm div id....

i've watched and waited for a browser update to happen along that would render it useless... or worse... but it hasn't happened yet.  if this is true (and i value your knowledge over my own) then there are a lot of items that can be tweaked by styling tags within defined divisions.  cool!

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,808
  • Master of BBC Abuse
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #11 on: July 16, 2019, 07:10:06 PM »
Never knew you could style br's, but they're block display by default anyway. Are you sure you don't mean hr's? They're block display too, but people often style them.

Anyway sure, you can just use descendants to style child elements of any defined parent element. Classes are only a convenience to make writing and maintaining CSS easier. There's no actual requirement to use them, so people just use them when they think it's going to make their lives easier. Using descendants is slower to process, but as long as you don't go overboard with long strings of them it's not really an issue. Once things get to the point where your descendants are becoming a bit gruesome it usually makes more sense to throw in a class and cut out some code. The other advantage is that providing you give the class a good, descriptive and easily understandable name (which people often don't :P ) it makes it more obvious what your code is doing. That's always handy when you come back to it after a break.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 702
    • College Football Fan Site CFB51
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #12 on: July 16, 2019, 07:31:36 PM »
Nope... BR's, not hr's for sure. I don't know if it responds to the block but it sure does the margin below, which is its value to my purpose. ... And as far as CSS goes, I've got a massive minified and combined file that needs to lose some weight... I wager a full third is no longer used. Its on my todo list.

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,808
  • Master of BBC Abuse
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #13 on: July 16, 2019, 07:55:51 PM »
The Line Break element - Styling with CSS

Quote
You can set a margin on <br> elements themselves to increase the spacing between the lines of text in the block, but this is a bad practice — you should use the line-height property that was designed for that purpose.

Must admit that would have been my go-to solution. Line-height is an obvious one to use for the purpose.

Offline drewactual

  • Sr. Member
  • ****
  • Posts: 702
    • College Football Fan Site CFB51
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #14 on: July 16, 2019, 08:31:56 PM »
It seems I recall trying it with mixed results... I did read that, bit tossed caution to the wind in using it.

Offline Wellwisher

  • Full Member
  • ***
  • Posts: 400
  • Gender: Male
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #15 on: August 17, 2019, 06:49:44 PM »
I was looking for this for ages. Thanks bud.  :)

Online Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,808
  • Master of BBC Abuse
Re: silly lightweight PM notification adjustment [2.0.15]
« Reply #16 on: September 24, 2019, 01:15:15 AM »
As it turn it out, I just resurrected this idea for something I was working on. This is a pure CSS option that works on default markup.

This CSS is simply this:

Code: [Select]
#button_pm strong {
display: inline-block;
position: relative;
z-index: 1;
margin: 0 -4px;
padding: 0 10px;
background: #f88c00;
color: #fff;
border-radius: 5px;
}

And it looks like the screenshot. The way it works is the relative positioning and z-index put the strong tag higher in the stack than the square bracket that comes after the strong. The negative left and right margins then pull the square brackets in so they are hidden behind the strong tag. The rest is just eye candy.

« Last Edit: September 24, 2019, 01:42:52 AM by Antechinus »