News:

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

Main Menu

Childboards as Dropdown

Started by Matthew K., March 12, 2009, 01:04:02 PM

Previous topic - Next topic

shadav

Quote from: Wellwisher on August 17, 2020, 04:42:37 PM
@shadav

I am not sure how your down list looks but on mine, the "New" icon is replaced with an asterisk (*). So basically if my drop-down list has an asterisk next to a sub-board, then it means there's new posts in that board (As shown on the image attached).

I managed to figure out how to add "New" symbol as text by doing the following modification:

On your current theme, find code in boardindex.template.php



echo '<option value="', $key, '">', $value['name'], $value['new'] ? '&#42;' : '', '</option>';



Replace with:




echo '<option value="', $key, '">', $value['name'], $value['new'] ? ' [New]' : '', '</option>';




8) 8) 8)

End result - see attached:

I can't get anything to show up on my site
but if you want the image to show, you could try replacing [New] with
<img src="' . $settings['lang_images_url'] . '/new.gif" class="new_posts" alt="" />
it should work, I would think....

Arantor

Nope, can't put images inside dropdowns.

You *could* possibly do some really funky things with CSS and backgrounds on elements but it's not recommended as select elements are not consistently styleable across browsers.
No good deed goes unpunished / All helpful urges should be circumvented

I have something to say: it's better to burn out than to fade away. There can be only one.

Wellwisher

#262
Quote from: Arantor on August 17, 2020, 08:40:53 PM

Nope, can't put images inside dropdowns.


@Arantor that was my next thought tbh.  8) However, I already love the result thus far with your help:

Final result:



@shadav Tried that, nothing showed. Let me know if you managed to find a way of adding the image. Here's the code that Arantor kindly offered for pushing the "New" icon to the left (as seen in the picture):

Quote from: Arantor on August 17, 2020, 07:47:56 PM


echo '<option value="', $key, '">', $value['new'] ? ' [New]' : '', $value['name'], '</option>';



CSS is the way forward because you can target each "option" and because the board value is always different. You should be able to use css "content:before"

e.g:



option[value=two] {background-color: yellow;}

[/quote]

Wellwisher

Crap:

Adding images via CSS may be tricky too (check out my JSfiddle mock-up).  Where the "option value" is "Alphabetic" we can target the yellow background color with CSS. However, where the value is "numeric", we're NOT able to target it.

Since the SMF board ID's are "numeric values" it will be a problem using CSS to target it.

https://jsfiddle.net/f8qtrLbk/2/

Arantor

Add a class to the options that are new, or data attributes. But rendering of images in selects in any form, whether it's with before or background images is woefully inconsistent, or at least used to be so, haven't looked f it's now better (but given some other stuff I see, I suspect not)
No good deed goes unpunished / All helpful urges should be circumvented

I have something to say: it's better to burn out than to fade away. There can be only one.

GL700Wing

I don't actually use this mod but I am working on a new mod that integrates with it.

I noticed this mod hasn't been updated for SMF 2.1 yet but because I know some people like @shadav are probably waiting for it (and because I want to finish my new mod) I decided to work out what changes were needed to get it to work with SMF 2.1 (fortunately only minor changes were needed to the installation original code) - one change of note is that 'child' boards in SMF 2.0 are referred to as 'sub-boards' in SMF 2.1.

To repackage the existing release of the mod to work with either SMF 2.0 or SMF 2.1 you'll need to do the following:
1.  Download and unzip the current Childboards-as-Dropdown.2.0.4.zip mod package file.
2.  Overwrite the existing 'package-info.xml' file with the attached file of the same name.
3.  Save the attached 'modifications-smf21.xml' and 'resources.zip' files to the mod package directory/folder.
4.  Unzip the 'resources.zip' file and confirm overwriting the file 'resources/cad_language/main.english.php'.
5.  Delete the 'resources.zip' file.
6.  Recreate the mod package zip file (eg, 'Childboards-as-Dropdown.2.0.4.zip').
7.  Install on either your SMF 2.0 or SMF 2.1 forum.
8.  Enjoy!
Life doesn't have to be perfect to be wonderful ...

Antechinus

Sources code: making easy front end changes difficult since 1873 :P

Mods & Themes | Revamped theme for this site | Dark theme for this site | GitHub for n00bz

Shades.

Quote from: GL700Wing on May 15, 2022, 08:20:29 AMI noticed this mod hasn't been updated for SMF 2.1 yet but because I know some people like @shadav are probably waiting for it (and because I want to finish my new mod) I decided to work out what changes were needed to get it to work with SMF 2.1 (fortunately only minor changes were needed to the installation original code) - one change of note is that 'child' boards in SMF 2.0 are referred to as 'sub-boards' in SMF 2.1.

Thank you! 8)
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

Advertisement: