Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 02 Mar 2016, 18:27
twistsol's Avatar
twistsol twistsol is offline
 
Join Date: Apr 2015
Real name: Chr's Phelps
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.

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
Reply With Quote
  #2  
Old 02 Mar 2016, 18:46
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Real name: Mark
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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

It appears the array $activeusers is passed to the template, and then the tag:

<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:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Former vBulletin.org Staff Member



Support for my products (as well as updates/new product publishing) has been moved to MHB - vBulletin Products and TAZ - Add-ons
Reply With Quote
  #3  
Old 02 Mar 2016, 19:18
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
https://www.vbulletin.com/docs/html/...mplates_syntax also contains some useful info regarding the syntax in templates.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #4  
Old 02 Mar 2016, 19:28
twistsol's Avatar
twistsol twistsol is offline
 
Join Date: Apr 2015
Real name: Chr's Phelps
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 03 Mar 2016 at 02:22 ---------------

It worked perfectly.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 09:03.

Layout Options | Width: Wide Color: