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 that 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:
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.
Related
I've been racking my brain about an easy way to generate an HTML table with rowspans with PHP that would look like this, numbers indicating each cell's rowspan:
I noticed that there is sort of a pattern in the rowspans if you go from left to right, top to bottom: 1,3,7,1,1,1,1,1,3,1,1. I'm not sure if that matters.
Also, I wonder if it's possible to use any method for the table above for a table like this:
maybe addressing your second example first is easier, but it might be adapted to the first example.
the structure of the tables in html is obtained using the rowspan an colspan properties.
try to picture the table as a closet, the rows as drawers and cells as boxes inside those drawers.
with these properties, u can "merge" the cells throughout rows and/or columns.
my approach would be to set a minimal block with the appearance and data that you need, ie your second example, and write it down in html.
the "php-cycle-the-thing-up" part would require you to use that html "template" in the loop dropping your recordset data in the td portions of the html.
in that way, i think you might get what your looking for.
on the other side, if you need the php to create the table dynamically, and merge the cells automatically in a set pattern, or even ignoring the pattern and simply adapt the structure as the data is coming, it would probably be better to look at the structure from the end.
because of the way that tables are built with html, nesting table-tr-td, building cycles with this look is tricky. have you considered simply nesting divs?
i'm new to stackoverflow, i wanted to comment but by the time i finished this, i couldn't remove the answer nor comment the question, sorry if this didnt quite help you... :S
write down, come up with the recursion formula for the table. you need to come up with the math with the least number ideally ZERO conditional statements.
it's not that hard. for a desktop, i use three columns if it detects a mobile devices, my php automatically switches to 1 or 2 columns depending upon screen size
I have two nodes, one is kind of a parent to the other node. For example, I'm displaying information about Plants. There are two nodes, Plant_Parent which has the latin name and some common names which is moderated, and then there is the Plant_Info which is not moderated and it has information like bloom time, growing experience, water requirements, stuff that's user specific. However, I want to be able to display the two together, i.e. someone selects a Plant_Parent node, and all the plant_info nodes are display as well.
Drupal doesn't seem to support this, is there a why I can do this?
The heavily-used CCK module has a Node Reference field type that's perfect for this.
Node reference as ceejayoz says can do two nodes displayed together. However you could also just have different permissions on fields within a node. Have a look at content_permissions which is part of CCK, or look at the sparsely documented hook_field_access() if you wish to have even more custom permissions.
I'm an admin for a page and I want to give certain users dynamic control of the menubar layout. The ideal would be a page with a list with menu items and arrows pointing up and down with each item and when you click them the item is reordered. I have a pretty basic idea of how I can do it but I would like some suggestions.
The items are stored in MySQL and I only need help figuring out how the items should be ordered or numbered and how to re-order them. This probably needs some javascript trickery and I'm not familiar with JS.
You could use jQuery UI draggable to reorder them.
As for saving them into MySQL, simply have an order column and save their position there.
Then when retrieving the records, just add ORDER BY 'order' ASC or similar (should be backticks).
This is virtually impossible to answer without knowing what constraints there are on the system - What,specifically is it you're having problems with? Is the code for rendering the menus already written? Not practical to change? If so what is the data structure?
You might want to look at PHPLM - it doesn't provide a graphical editor last time I looked - but it is reasonably well written, cross platform and can accomodate a range of data structures.
I've got a client that requires that an article be displayed in two, sometimes three, columns in Joomla. I am fairly sure they won't be happy with having to edit 3 articles for 3 columns so the splitting would have to be done automatically.
I've done something similar before where it'll split a chunk of HTML into n columns, but have no real idea how to accomplish this within Joomla itself.
Any ideas gratefully recieved!
An alternative approach:
Use Javascript to split up the Article in several column in the browser. Here I could imagine a full-automated approach could work.
Advantages (over the first approach):
As Javascript can know, which height the paragraphs actually have in the browser (unlinke PHP), you could find the optimum split more accurately.
This can be implemented in the template php-File: you tell the template to include the js-File. So it could be made context-dependent,E.g.: If the left column is collapsed (because there are no modules in it), tell the JavaScript-File to initialize to 3 columns, else 2 columns.
However, have in mind that it should rest usable for those who have Javascript disabled.
This doesn't seem to be easy.
At first thought this should be an CSS attribute, but if it exists, it is part of CSS 3.0 and as such only understood by modern browsers (if at all). But I didn't find any way to do this in CSS.
So you actually have to modify your HTML code. I would propose the following:
A Button (editor-xtd plugin) that splits the article into several parts, each one for one column, showing a dotted line in the editor box (similar to the "read-more"-Button).
E.g. it inserts in the article: (you will have to define hr.column in /templates/system/css/editor.css).
A (content) plugin that creates the multiple colum-style,
E.g. replacing the hr-Tag with table or floating divs.
This way, it is half-automized, without mangeling in the Joomla! files but only adding to extensions to it.
the CSS 3 rules for multi-columns are:
-column-width
-column-gap
-column-rule
-column-count
with the vendor label (-moz, -webkit) before.
More info at http://www.css3.info/preview/multi-column-layout/
I would use css and tell the people with Explorer to change browser! (i'm jocking of course)
Otherwise javascript is the way like said before. This script should do (not tested) http://13thparallel.com/archive/column-script/
This should be done through the template, some PHP coding is involved.
One of our clients asked us to do the exact same thing before, and we have done it through template. Note that for very small articles we increased the font in order to split the article into 3 columns.
Apologies for the awkward wording in this question; I'm still trying to wrap my head around the beast that is Drupal and haven't quite gotten the vocabulary down yet.
I'm looking to access all rows in a view as an array (so I can apply some array sorting and grouping functions before display) in a display output. The best I can tell, you are able to access individual rows as an array using row-style output, but seemingly not in display output.
Thanks!
You have to change the Row style setting: to NODE.
Click on Theme Information.
Create an file with the name of one you find in the Display output point (I would use the second one eq. views-view--portfolio.tpl.php)
And now you can use your own Node Template and access the $node variable.
Ultimately, I had to use node_load on each item and load the results of that into an array. Inefficient, but it worked.
I found this thread on Drupal.org about this question, but those solutions don't quite work.
How to get a "result Array" with views_get_view() (as with views_get_current_view())
They return only the list of IDs, not the actual rendered fields.