Topic on Project:Support desk

Infoboxes not populating correctly

4
Summary by Chinghis

Summary: External data is used to populate Infoboxes, but incorrect data from the first box would display in all of the following Infoboxes, rather than displaying the correct data. Bawolff pointed me in the right direction and I was able to determine what I needed to do to get the infoboxes to display correctly: Use "{{#clear_external_data:}}" to 'clear all external data that has already been retrieved' (from the MediaWiki page on the External Data extension).

Chinghis (talkcontribs)

OK, this may take some explaining. I know only a little HTML, and less about making a wiki work. We use a locally hosted MediaWiki for our Systems Support team. We use an infobox to display pertinent info about PCs or other devices, and on some pages we can have three or four boxes. The infoboxes pull the info from an inventory database. When originally set up, the database was a CSV file. Since that time, and even before I started, the inventory was moved to Snipe-IT and MySQL.

The problem with our Wiki now is that most of the infoboxes were not updated to pull from the correct location.

This was the old code:

{{#get_file_data:file=inventory-computers|format=CSV with header|delimiter=,|data=title=Title,location=Location,hostname=hostname,label=Label(s),IP=Static IP address,MAC=MAC address,access=Remote Access,device=Device,servicetag=Service Tag,expressservicecode=Express Service Code,bios=BIOS Version,os=Operating System,network=Network Drop,video=Video Drop,audio=Audio Drop|filters=title=KIOSK}}

And here's the Infobox code that we use:

Finally, here’s how I have determined that the code should be written to pull from the correct database: </nowiki>{{#get_db_data:db=snipeit|from=assets a JOIN locations l ON l.id=a.location_id Join models m ON m.id=a.model_id|where=a.name='KIOSK'|data=title=a.name, location=l.name, label=a._snipeit_labels_5, Asset_tag=a.asset_tag, MAC=a._snipeit_mac_address_1, os=a._snipeit_operating_system_2, hostname=a._snipeit_hostname_3, access=a._snipeit_remote_access_6, servicetag=a._snipeit_service_tag_7, expressservicecode=a._snipeit_express_service_code_8, bios=a._snipeit_bios_version_9, network=a._snipeit_network_drop_10, support=a._snipeit_support_url_17, IP=a._snipeit_ip_address_4, device=m.name}}

</nowiki> On the first few pages that I updated with this code, all was well – it pulled information from the correct database, etc. But the problem occurs when we have two or more infoboxes on the page: It seems to pull info from the first box on the page to create any boxes that follow, and then duplicates the older info again in the same box. Unfortunately, our wiki is not publicly accessible so I can’t direct you to an example. But I’m thinking this is probably very elementary and I’m just missing a bracket or something. Thanks! Here are the particulars on our setup. We do have the ParserFunctions extension installed, as well. MediaWiki version: 1.29.1 PHP version: 7.0.33-0ubuntu0.16.04.16 (apache2handler) Database type and version: MySQL, 5.7.31-0ubuntu0.16.04.1

Chinghis (talkcontribs)

Just came back to say thanks, Bawolff - you pointed me in the right direction. The MediWiki page on the External Data extension suggested that when you have external data populating a template that's called more than once, you need to clear external data that's already been called. Inserting #clear_external_data after every Infobox section seems to work. Thanks very much!

Bawolff (talkcontribs)

the get_db_data is a fairly obscure extension. My first guess would be bug in the extension.

Chinghis (talkcontribs)

Thanks! I will look into that a bit.