#Rendering multiple tables in Lua per page parsed instead of one big table which includes all pages

6 messages · Page 1 of 1 (latest)

fierce birch
#

I have a Lua module that parses pages with infoboxes and a returns a table with information from the infoboxes on the pages that match. (Viewable on this template.)

Right now, it renders a table with all of the items that match the query (this begins on line 68 of the module). How would I direct it to render a table for each page that matches the query, with the items inside?

For instance, I want a table with the four items on the page "Sweet Dumplings," then a table with the four items on the "Yak Cheese" page, then "Pancakes," etc. (Right now they're all in one table.)

(I know I can do this with separate DPL calls in the template using titlematch, but I would like it to be as automated as possible, without me having to edit the template to add a new DPL call each time that a new page is made.)

austere nimbus
#

not exactly sure what you want here. are you asking about being able to get data from multiple pages? are you asking about how to separate out the different tables?

fierce birch
#

Yes, separating out the tables, basically - right now they all return in the same table, and I want the tables separated per page name!

austere nimbus
fierce birch
#

But how do I handle that in the module? I'm not worried about the formatting per se, but about rendering many different tables in the module (per page parsed) instead of one big table per all pages parsed (if that makes sense)

#

oh I GOT IT (with help from another server too)

I added a new local variable to the p.main function named tables then added this bit to line 63

          tables = tables ..
          tostring(p.create_table(pages ,frame))```

and returned `tables` instead of `p.create_table(pages, frame) `

<https://dappervolk.miraheze.org/wiki/Module:Alchemy_Chain_Pet_Food?diff=35096&oldid=35092>