Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By bfbryan on
I have a query in a custom module that produces 2 colunes of data. The potential exists for the list to be long. I'd prefer to split the list into 4-6 columns (2-3 major lists) and show more the data per page vs white space on the right. Can someone suggest how I can theme this?
Comments
It can be done
The details somewhat depend on if you using tables are ok or not. This example uses tables and is untested (i.,e. it may have typos :) )
I am getting a Fatal error: Call to undefined function: is_empty
It is referring to the line if ( ! is_empty($row) ) {
I don't know if it is due to other stuff I have in my query. Here it is:
Typo on my part
;is_empty; should have been 'empty', so
should have been
This works great but is there a way to list down vs across?
Right now it orders it across each column. Looking for:
A D G
B E H
C F I
vs.
A B C
D E F
G H I
Thanks
One more item
How do I carry the header also into each column?
Not sure what you mean
Do you want the header text to appear in each table cell?
Question
Does 'A' represent one column of data or two (the orginal problem was pairs of data in multiple lists on a page)
A represents one set of data or a list. In this case 2 columns.
Looking to display the header across both lists.
Data by row first (instead of column first)
This version should place the data by row first and also repeats the heading titles for each list
Awesome, I followed some of the logic there
but some is confusing. Regardless is works great. Thanks again for your help.
combine the offset with 2 columns?
nevets ,
I am trying to combine the table group/offset code you gave me before and the 2 columns. I got most of it except I think I have something out of order. All the nodes (ticker and title) are listed in the 2 columns and the sectors are listed too but all the sectors are listed below in the first column. Any insight as to what is out of order. Thanks again.
That complicates things a lot
The reason you see them added at the end is the code pre-builds the empty table before looping through the data.
Since you want the data in the form
A D G
B E H
C F I
you have complicated the problem considerably.
Consider the following pairings where letters represent the data and numbers the sector
A - 1
B - 1
C - 2
D - 2
E - 2
F - 2
G - 3
H - 3
I - 3
Would you want the final result to be
1 C 3
A D H
B E I
2 F J
or maybe
1
A B
2
C D E
F
3
H I J
or maybe something else. I will leave it up to you as an exercise to decide what format you want and how to achieve it. One parting though, you could produce a "normal" table with just the 3 columns and one list then split in N parts (Where N is the number of lists) and buildup the secondary table for display using the N lists.
I logically
it would make sense to do the last option where it groups them together by $sector with 2 lists in each. I had it set to just group with a single list but it didn't utilize the space appropriately. You know, always trying to avoid going beyond the fold.
One more time
This version combines logic from the first version (data goes across first, then down), adds the header logic from the second version and adds rows with the section link as needed. It also adds the spacer column at the start of each list
subscribing
subscribing