The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Passing array to a template to format as a table
I'm a newbie to HTML, CSS, PHP and relatively new to vBulletin, admin for less than a year, and I literally wrote my first php code yesterday. Old COBOL guys can still learn new things. :up:
Last night I created a script that gathered some data from the database and formatted it as an HTML table in the PHP script and passed that variable with text to a page and template I created by following tutorials I found here. The output on the page was fine but I'm questioning the technique. I think it would make more sense to pass a variable as a two dimensional array to the template and have the template code display it broken out into a table to display on the page from that point. Is this possible? If so can someone provide some hints as to what I'd need. If it matters, vb 4.2.3 PHP 5.4.45 Apache 2.4.16 OSX 10.11.3 Thanks much for any assistance. Chris |
#2
|
||||
|
||||
Hello and welcome to vBorg, Chris!
While I haven't personally used this feature, I think what you're after is like what you find in the "FORUMDISPLAY" template: HTML Code:
<ol class="commalist"> <vb:each from="activeusers" value="row"> <li><a class="username" href="{vb:link member, {vb:raw row}}">{vb:raw row.musername}</a>{vb:raw row.invisiblemark}{vb:raw row.buddymark}{vb:raw row.comma}</li> </vb:each> </ol> <vb:each from="activeusers" value="row"> iterates for each row in the array, and gives the name "row" to the rows during the iterations. So, I'm thinking you would do something like: HTML Code:
<table> <vb:each from="myarray" value="row"> <tr> <td>{vb:raw row.column1}</td> <td>{vb:raw row.column2}</td> <td>{vb:raw row.column3}</td> ⁞ <td>{vb:raw row.columnn}</td> </tr> </vb:each> </table> |
Благодарность от: | ||
twistsol |
#3
|
|||
|
|||
<a href="https://www.vbulletin.com/docs/html/main/styleref_templates_syntax" target="_blank">https://www.vbulletin.com/docs/html/...mplates_syntax</a> also contains some useful info regarding the syntax in templates.
|
#4
|
||||
|
||||
Thanks Mark, I think that's exactly what I was after. I'll need to look at it tonight when I'm not doing my day job.
Thanks also Dave. Clearly I need to spend more time reading about all of this stuff but time, as they say, is a commodity in short supply. Chris --------------- Added [DATE]1456975358[/DATE] at [TIME]1456975358[/TIME] --------------- It worked perfectly. |
Благодарность от: | ||
MarkFL |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|