[DEV]CollapseCategories

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
Post Reply
User avatar
Alg
Registered User
Posts: 76
Joined: Thu Aug 07, 2014 7:13 pm
Location: Israel
Contact:

[DEV]CollapseCategories

Post by Alg »

Extension Name:CollapseCategories

Extension Description:: expands/collapses categories on the index page and save state for each category in the database (read more details in Readme https://github.com/alg5/CollapseCategor ... /README.md
Extension Version:: 0.0.1 (unstable)

Requirements:
  • phpBB 3.1.0-RC4 or later
for try to use in 3.1.0-RC3 you must change content of file phpBB / includes / functions_display.php
new content can be found here: https://github.com/rxu/phpbb3/commit/0a ... a6e1f9bde3

Development repository: https://github.com/alg5/CollapseCategories

Download URL: Download button named "Download ZIP" can be found at the development repository page.
Installation: Extension files should be extracted to /ext/alg/CollapseCategories/ folder. Then the extension should be enabled in ACP as usually.

Precaution: As the ext is still in development, major changes still can be applied which could require full extension purging and reinstallation, so use it on your own risk. DO NOT install it on production boards. For testing purposes only.
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5164
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: [DEV]CollapseCategories

Post by MattF »

Why are you injected so many unused variables into your constructors? From what I can see, you are only using $db and $user in the event class, and just $db in the controller.

Also, your sql queries are very unsafe, and should follow the coding guidelines outlined in the WIKI sections of area51.phpbb.com. At the very least you should be casting those integers as (int) and sql_escapeing strings.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
PayBas
Former Team Member
Posts: 930
Joined: Thu May 25, 2006 12:37 am

Re: [DEV]CollapseCategories

Post by PayBas »

Also, the code doesn't seem to be very efficient.

You are calling the display_forums_modify_template_vars and display_forums_modify_category_template_vars functions within foreach loops. This basically means that you are creating DB queries for every single forum row.

On a big forum, this would probably multiply the number of DB queries significantly, increasing load.

On a personal note. I usually tend to simply use JS + a cookie for collapsing categories, instead of more complex php + sql. Been using this script for my styles for years: https://github.com/danielstocks/jQuery-Collapse
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5164
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: [DEV]CollapseCategories

Post by MattF »

Agreed JS+Cookies is the standard way of collapsing categories...such as in the collapsible categories I did for my Precise Similar Topics MOD.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
Татьяна5
Registered User
Posts: 142
Joined: Wed Feb 13, 2013 5:30 pm
Name: Tatiana

Re: [DEV]CollapseCategories

Post by Татьяна5 »

Does not agree. With JS+cookies can not be closed category on the all used devices (phones, computers, etc.) together
JS useful for closing one block but not for many
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5164
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: [DEV]CollapseCategories

Post by MattF »

Татьяна5 wrote:JS useful for closing one block but not for many
Sure it is! PayBas's styles do it just fine, and so does Christian Bullock's styles. He even has a great and simple write up on how to do it here: http://www.christianbullock.com/2011/ph ... th-cookies
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
david63
Registered User
Posts: 17942
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: [DEV]CollapseCategories

Post by david63 »

I also agree about not storing this data in cookies due to accessing a forum on multiple devices
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
MattF
Extensions Development Coordinator
Extensions Development Coordinator
Posts: 5164
Joined: Sat Jan 17, 2009 9:37 am
Location: Los Angeles, CA
Name: Matt Friedman
Contact:

Re: [DEV]CollapseCategories

Post by MattF »

david63 wrote:I also agree about not storing this data in cookies due to accessing a forum on multiple devices
How many devices you gonna be using? And how many forums need collapsing? You just have to do it once (per device) and then done (unless you blow out cookies)

Also with cookies, your collapsed prefs will remain when you are logged out.

It really should be a JS Ajax script that sets a cookie and runs a quick php script to also save the setting to the db like we did with the board announcements extension.
Formerly known as VSEMy ExtensionsPlease do not PM me for support.
User avatar
SiteSplat
Registered User
Posts: 82
Joined: Sun Sep 07, 2014 7:17 pm
Contact:

Re: [DEV]CollapseCategories

Post by SiteSplat »

Татьяна5 wrote:Does not agree. With JS+cookies can not be closed category on the all used devices (phones, computers, etc.) together
JS useful for closing one block but not for many
Using the DB to store stuff, 2 entries probably for closed and opened state adding loading and potential security issues is not a good idea. There are better and more modern solutions, that will handle the job properly from the client side rather the the DB. For example my "Smart Collapse" addon for FLATBOOTS (Premium phpBB style) uses HTML5 local storage to deal with this and also I added the possibility to drag and drop, refresh (needs server side), close and collapse any custom panels. All done painlessly via HTML5 local storage:-) and btw there is a button to clear the storage session as well.

SCREENS:

Image

Image

Image

Image



With this being said, I think it's important to thank the author of this post for his contribution and idea. ;)
Ninja Scott
Registered User
Posts: 29
Joined: Thu Jan 10, 2013 7:38 pm

Re: [DEV]CollapseCategories

Post by Ninja Scott »

Anymore movement on this or can anyone suggest a mod that collapses categories and it ready for 3.1.x?
User avatar
Louis7777
Registered User
Posts: 247
Joined: Sat Apr 21, 2012 9:22 pm

Re: [DEV]CollapseCategories

Post by Louis7777 »

SiteSplat wrote:uses HTML5 local storage to deal with this [...] close and collapse any custom panels. All done painlessly via HTML5 local storage:-) and btw there is a button to clear the storage session as well.
Yeah, HTML5 Local storage ftw :)

I'd say use HTML5 Local storage for guests, but for logged in users imo the settings should be stored in the database (via Ajax).
Post Reply

Return to “Extensions in Development”