开发者

Multi-Level Bullets Implementation

开发者 https://www.devze.com 2022-12-19 22:45 出处:网络
What is the best way of implementing multi-level lists/bullets in php? What I\'m trying to implement is a system to take in short phrases, and categorize them within sections. However, at the same t

What is the best way of implementing multi-level lists/bullets in php?

What I'm trying to implement is a system to take in short phrases, and categorize them within sections. However, at the same time, I would like to have each section to be collapsible and capable of having sub-sections within them.

For Example: Section 10

Section 10.X

Section 10.X.X

I was thinking of having each sub-layer as an array, but I realize that I've seen the same type of collapsibility in many places, and they all seem to be similar. Maybe there already is a package or library th开发者_高级运维at does this? And if there is, how should my data-structure for keeping each entry be structured?


Your bullets are being done in HTML, as PHP merely generates HTML code. Consider using nested <ul> tags.

The collapsing is most probably going to be javasscript. (Although I wonder if the CSS :active psuedoclass would work in supportive browsers...)

Regarding the package, I'm not sure. You essentially need a recursive list generating function.


For the kind of structure you mentioned, i think you need what is know as Tree View. Check it out on how to implement that.

Screenshot:

Multi-Level Bullets Implementation


Anything to do with toggling, display lists, indenting etc should be achieved relatively easily with HTML/CSS/Javascript.

Inside your category table, you could create a parent_id field which matches to your primary ID. Then run loops to display your TLD as well as another loop to display the categories within the parent.

0

精彩评论

暂无评论...
验证码 换一张
取 消