Dynamically indented text display I'm happy to say that I've succeeded in importing an Access database into MySQL and getting a table from it to show up in Views. Progress! Thank you for all the help I’ve been getting here to overcome the hurdles along the way.

So now, the first webpage I'm working on has a rather unusual HTML table on it that’s a bit of a hack and I wonder if Views is capable of making it or if I need to find a different way.

You could call what I’m trying to do a “dynamically indented text display.”

On the current website, the javascript that builds the main part of the HTML table looks like this:

'&lt;TR>' + (nLevel == 0 ? '' : '&lt;TD ColSpan="' + nLevel + '">&nbsp;&lt;/TD>') +
     '&lt;TD ColSpan="' + (13 - nLevel) + '">' + 
          (sHeading  == '' ? '' : sHeading + ' ') +
          (sParty    == '' ? '' : '&lt;small>' + sParty + ':&lt;/small> ') +
          (sURL      == '' ? '' : '&lt;a HRef="' + sURL + '" target="_blank">' + sLinkText + '&lt;/a>') +
          (sNotes    == '' ? '' : sNotes) +
          '&lt;/TD>' +
     '&lt;/TR>'

In the data table, every row has (a) a value of nLevel between 0 and 12, inclusive, and (b) either a value of sHeading or a value of one or more of the other text variables. Therefore, every row of the HTML table has either a heading or a text block, and whichever it is is indented by an amount controlled by nLevel.

Two elements of simple logical processing stand out there:

     The numeric variable, nLevel, determines the level of indentation by a pair of &lt;TD ColSpan=> tags in which the sum of the “ColSpan” parameters is 13. So there are 13 levels of indentation (from 0 to 12) across the page. (On the current page, the width of the indentations is set by 12 repetitions of “&lt;TD width="25">&amp;nbsp;&lt;/TD>” in the first row of the table.)
     A link is constructed from the variables sURL and sLinkText.


I see that Views allows for the calculation of a math expression in the construction of a table, but I don’t see anything that allows for this kind of programming there. So I’m thinking a Views table won’t work, unless there’s something I don’t know.

It’s possible that an HTML list could work if Views allows for nesting of lists, which would control the indentation. When nLevel increases from one row to the next, it always increases by one, so this gives the same behavior as “&lt;UL>” (plus a bullet, which I could live with). But still, I would have to be guiding Views programmatically in its placement of “&lt;UL>” and “&lt;/UL>” tags, and I don’t see how I would do that.

Maybe now you can see why I was originally thinking of just translating the code from javascript to PhP and putting that directly on the page. The code is pretty simple, so that would be easy. (The part that I still don’t know how to do is how to connect to the database with a query to get the values of the variables above.) But when I posted my question about whether this was a good idea, I got some strongly worded advice that it’s usually a very bad idea to put PhP code directly on the page.

So what is the right way to get Drupal to do the kind of dynamically indented text display described above?

Thanks for your help.
depending on you exact set up (which you may be able to modify to suit), you could look into Views Tree module:


  This module provides a tree-based style plugin for Views. It is
  equivalent to the tree-based style template from Views 1.
  
  It is based off of the list style. Although it generates a nested
  view, there is still only a single query run for the view making it
  quite performant.