Tidy Child Boards

Started by Sir Osis of Liver, August 10, 2019, 05:44:13 PM

Previous topic - Next topic

Sir Osis of Liver

I know this mod is officially gone and unsupported, but it's still very useful (and I like it :)).  Has any one tried making it responsive so different number of columns can be displayed on narrower screens (i.e., 4 on pc, 2 on phone)?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

No, and it would need a fairly stiff rewrite to make that work (especially seeing that it makes the configuration somewhat pointless if you set it for x columns and it gets changed to y columns anyway)

As for 'gone', it's been available for years from https://github.com/Arantor/tidy-child-boards-2 including a fork that did things I didn't like (hence the never-accepted pull request)

SychO

for 2.1 it can be updated to be purely made out of hooks, which is neat.
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Arantor

Nah, it'd be possible to do it in 2.0 with hooks but it'd be ugly.

If you were to do it, here's how you'd do it:

1. Load a file during integrate_pre_include and attach a hook to integrate_pre_load
2. This file needs to examine the state of $_GET['action'] and if it would notionally display boardindex, explicitly make it action=boardindex
3. During integrate_actions, add action=boardindex to point to a function in the plugin (the one just added during integrate_pre_include)
4. This new function loads BoardIndex.php, calls BoardIndex, and then modifies $context to find boards with child boards, mark them as not having children (so the normal sub-boards rendering doesn't kick in), and appends the rendered layout of the sub-boards to the board's description

Making it work also with any of the portals isn't really challenging - during integrate_actions, have it check if something already exists for action=forum, save that somewhere, run that instead of explicitly BoardIndex.php/BoardIndex(), but either way you're wrapping an action around the board index so you can change global $context state after it has processed but before it hits the rendering system.

Not like this is a new idea, SimpleDesk did exactly this in its 1.0 version to add stuff to unread replies without a hook ;)

Sir Osis of Liver

Hmm, well, one problem is the board names don't wrap, so they overlap when squeezed together on a narrow display.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Antechinus

You could fix that with CSS. Ditto for the responsiveness (although it would mean setting the number of columns in the CSS rather than in admin).

Arantor

Well, yes, that's kind of the point, the config says 3 columns. That doesn't mean, or say, '3 columns except when it should be 1 on these widths', that's not something that can be expected to be sanely configurable in the admin panel...

But someone is welcome to take a look at the code and add the necessary CSS to it.

Thing is, if you're already doing that in CSS, you might as well skip this mod and just do it in straight CSS (although this will have a slightly different behaviour; wrapping it with pure CSS will make the boards be listed going across, rather than down the columns, but even that's achievable with the newer columns CSS)

SychO

Quote from: Arantor on August 10, 2019, 06:43:30 PM
Nah, it'd be possible to do it in 2.0 with hooks but it'd be ugly.

If you were to do it, here's how you'd do it:

1. Load a file during integrate_pre_include and attach a hook to integrate_pre_load
2. This file needs to examine the state of $_GET['action'] and if it would notionally display boardindex, explicitly make it action=boardindex
3. During integrate_actions, add action=boardindex to point to a function in the plugin (the one just added during integrate_pre_include)
4. This new function loads BoardIndex.php, calls BoardIndex, and then modifies $context to find boards with child boards, mark them as not having children (so the normal sub-boards rendering doesn't kick in), and appends the rendered layout of the sub-boards to the board's description

Making it work also with any of the portals isn't really challenging - during integrate_actions, have it check if something already exists for action=forum, save that somewhere, run that instead of explicitly BoardIndex.php/BoardIndex(), but either way you're wrapping an action around the board index so you can change global $context state after it has processed but before it hits the rendering system.

Not like this is a new idea, SimpleDesk did exactly this in its 1.0 version to add stuff to unread replies without a hook ;)

damn that's interesting it's tricky but it works indeed, I never tried using the hooks as such, but that shows that you can actually do a lot even if there are few in 2.0

in 2.1 though you'd just have to edit all of the board types to something like 'tidy' using one of the appropriate board hooks (integrate_boardtree_board I think ? I don't remember) and load a file containing the function 'template_bi_tidy_children' where you can output them however you like.

I did the same with my FA Board Icons mod. Only issue is if you have another mod that uses the same approach then one of them will not work.
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Antechinus

Quote from: Arantor on August 10, 2019, 06:47:11 PM
Well, yes, that's kind of the point, the config says 3 columns. That doesn't mean, or say, '3 columns except when it should be 1 on these widths', that's not something that can be expected to be sanely configurable in the admin panel...

Obviously not, but you can bet someone will demand it. :D

Arantor

Quotedamn that's interesting it's tricky but it works indeed, I never tried using the hooks as such, but that shows that you can actually do a lot even if there are few in 2.0

The nastiest hook I did in SMF 2.0 is one for 'if you delete a membergroup, call a function' which is the obvious example of a hook but 2.0 has no hook. So I spliced something off integrate_redirect to look for 'redirection from we have just deleted a board' and used that.

The first rule of hooks is to not get hung up on the name of the hook, because most hooks can be abused in various ways as mutators of global scope, the trick then becomes finding the one nearest to what you need, that runs no later than when you need it to run by.

Quotein 2.1 though you'd just have to edit all of the board types to something like 'tidy' using one of the appropriate board hooks (integrate_boardtree_board I think ? I don't remember) and load a file containing the function 'template_bi_tidy_children' where you can output them however you like.

That sounds familiar, did I hack that in back in 2013? XD

QuoteI did the same with my FA Board Icons mod. Only issue is if you have another mod that uses the same approach then one of them will not work.

Yeah, that's awkward, which is the one benefit of the kind of nested approach I mention - if all the mods take the view when hijacking integrate_actions to look at what is there and wrap themselves around it, it becomes possible to have everything playing somewhat nicely.

QuoteObviously not, but you can bet someone will demand it. :D

This is why I removed my mods from the mod site, fed up dealing with asinine souls that felt their time was more important than mine.

SychO

Quote from: ArantorThat sounds familiar, did I hack that in back in 2013? XD

ah now that you say that, the hook is actually integrate_getboardtree, yea that's the one you added in 2013 lol

Quote from: ArantorYeah, that's awkward, which is the one benefit of the kind of nested approach I mention - if all the mods take the view when hijacking integrate_actions to look at what is there and wrap themselves around it, it becomes possible to have everything playing somewhat nicely.

Indeed
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

Sir Osis of Liver

Interestingly (or not), child board titles wrap in 2 column mobile display in Nightbreeze theme, so they don't overlap.

Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Arantor

That's technically almost certainly a bug. If you look back through the TCB thread, this happened on other themes that did weird things in their CSS.

Advertisement: