Extension talk:Cargo

Magic Words and Fields
I'm using CONCAT in  to take one database field and construct some special wikitext before it displays. I do need to use magic words which is causing an issue I can't resolve.

As a simple test  works fine with the "r" in "Actor" converting to an "x" to make "Actox".

However, if I had add a database field it no longer works. . Role.position returns "Actor", and even with the magic word conversion, it still returns "Actor" instead of "Actox". 70.160.223.43 11:53, 12 August 2023 (UTC)


 * I would recommend doing the whole thing within SQL, i.e. using the function REPLACE instead of creating a call to #replace - that should work better, if I understand what you're trying to do correctly. Yaron Koren (talk) 13:08, 15 August 2023 (UTC)
 * You can escape curly braces by creating templates that return 🇦🇩, e.g: Template:(( that contains  and a matching Template:))  which you then call like   to get a working template Ivlvlvllvlvlvlvlvlvl (talk) 13:50, 2 September 2023 (UTC)
 * That is a really useful comment, thanks. I wish I'd thought of that years ago. Jonathan3 (talk) 22:23, 2 September 2023 (UTC)

Store a different boolean value
How to I store a different value than "Yes" or "No" in the Cargo table when using a checkbox in Page Forms? I thought adding something like to #cargo_store in the template would do it, but I still see Yes or No values: |Test= Alternatively, can a different value be stored by adding parameters to the form itself? Tahoma403 (talk) 09:25, 2 September 2023 (UTC)


 * What do you want to do? If it's to display things as "first" or "second" then you could handle that in the template displaying the infobox/query. Jonathan3 (talk) 22:19, 2 September 2023 (UTC)
 * Don't ask me why, but I actually want to reverse the stored Yes or No values, so that an unchecked box stores Yes in the Cargo table and vice versa. I'm aware that I can query the data to display different values. Tahoma403 (talk) 04:38, 3 September 2023 (UTC)
 * Why are "first" and "second" in that call? Shouldn't it be "No" and "Yes"? Yaron Koren (talk) 12:24, 6 September 2023 (UTC)
 * Sorry, I put "first" and "second" to clarify that I wanted different values stored than the standard Yes or No, but in reality I want the reversed No/Yes for the checkbox/boolean entry. Neither first|second or No|Yes seem to work. Tahoma403 (talk) 13:20, 8 September 2023 (UTC)
 * I have no idea - that seems like it should work. Yaron Koren (talk) 15:09, 8 September 2023 (UTC)
 * I figured I needed to change the field type from Boolean to String to make it work. Tahoma403 (talk) 12:06, 9 September 2023 (UTC)

Queries fail depending on the order tables are listed
Testing the staging version of a wiki that will be upgraded from MW 1.37.2 and Cargo 3.0 to MW 1.40.0 and Cargo 3.4.1, we have come across an issue on the updated site where queries that were working are now failing. The cases l've encountered happen when you are joining 3 tables: if the primary table (the one included in both join clauses) is listed last, the query that is generated looks like ... ..., which fails with a sql error. If the primary table is listed first or second, you instead get a working query: ... ... Ivlvlvllvlvlvlvlvlvl (talk) 14:07, 2 September 2023 (UTC)


 * Handling of the "join on" order was improved a lot in the latest Cargo version, 3.4.3 - I would recommend upgrading to that one. Yaron Koren (talk) 00:58, 3 September 2023 (UTC)

Compound queries overall order
Hi everyone, I'm looking to make compound queries to output in the "template" format but for my application I need an overall order option, so the output of the two queries are mixed. Currently, the output is the output of the first query, followed by the output of the second query. Is it possible to change this? Thanks Garuda3 (talk) 15:36, 2 September 2023 (UTC)


 * Until you get a better answer - I think that recently I thought about this and concluded that it wasn't possible, as there are very few possible options outside the individual queries within #compound_query. I guess that it would be possible via a Lua/Scribunto module. Jonathan3 (talk) 22:22, 2 September 2023 (UTC)

Query showing each item of "List" field on separate row
If Field_A is a Cargo list field, could you do a query ending up with a table like this?

A     | Page ---+--- abc   | Page1 def   | Page1 xyx   | Page2 Jonathan3 (talk) 21:52, 13 September 2023 (UTC)


 * Sorry for asking too soon. I worked it out with #arraymap and the template output format. Jonathan3 (talk) 22:01, 13 September 2023 (UTC)
 * You could also do this by just directly querying the "field table", i.e. the table named MainTableName__FieldName. Yaron Koren (talk) 13:06, 14 September 2023 (UTC)

Dynamic Table format issues
When testing dynamic tables format, seems there's no way to disable "hidden fields" toggles and text, or is there? --There's no unique class around the toggle text, but there are for toggle links (I can hide part, not all). I had to wrap the query in a div (with a matching page background color) and then set a negative margin, to moving the dynamic table up/over the unwanted "hidden" field toggles, to truly hide them. This allows such columns to be searched on still (say if they contained keywords, or text for images/icons I don't want displayed in the table). Though this isn't ideal, as there's a flash of all content on load before it "hides".

I tried to move said fields under "details fields" instead, but these are unexpectedly not searchable, why? Further, specifying a field in "details fields" that's already been added to the "hidden" ones, removed it from "hidden fields" (now they're no longer searchable... which is an issue, though perhaps making these work together is problematic). I ended up having to double-specify the same fields in both places, with different names, to be both searchable and folded up below each record in bottom (+) section.

The above seems unituitive, to just move the cell value toggles from between record to below them... also while still having them searchable--and it all displays initially until full page load, creating a bit of a visual snarl. Is this the intended behaviour in either case? After a certain number of columns, it makes better sense to have fields below, rather than between, especially for mobile... however, they need to be searchable. FrozenPlum (talk) 01:31, 17 September 2023 (UTC)

I wish the DataTables maker had labelled toggle columns as "toggle columns" (accurately describing function), and that Cargo had an option for toggle label/link visibility. Further, it would be great for all fields to be searchable by default, with an optional field to exclude some as desired (it's unclear what the logic was behind the different functions of the two similar features, displayed in different locations).

Also, for the "details fields" fold out, if the data is from the same table all fields are confined to the first cell only, even though the fold-out is quite wide--the only exception to that is list data, which does a colspan and extend through all columns. I can see from other examples that maybe join data goes left to right, but same-table "more details" goes from top to bottom in a left-to-right layout.

Hopefully Yaron doesn't mind that I added to the docs a couple things I found the hard way:
 * "details fields" are not searchable (currently).
 * Only indexed fields can display in "details fields".

FrozenPlum (talk) 01:31, 17 September 2023 (UTC)


 * The fact that "details fields" are not searchable is definitely worth including in the documentation, yes. And you're right that the functionality of "dynamic tables" is generally constrained by whatever is in the DataTables JS library, for better or worse. What did you mean by "Only indexed fields can appear"? Is that the same as what's in the previous sentence in the documentation, "each such field must be included in the  parameter as well"? Yaron Koren (talk) 13:27, 18 September 2023 (UTC)
 * Thanks for confirming the first. For the second, no, fields of a type that are "unindexed" as listed here will not appear at all in the details fields drop down (these were specified in the "fields" parameter)... I could not get any "Wikitext" type (non-indexed) fields to appear in "details fields" fold-dowm, despite being included and successfully useable elsewhere in the same table. MW 1.39.4, Cargo 3.4.2. Php 8.0.28. FrozenPlum (talk) 10:50, 20 September 2023 (UTC)
 * Oh, you're talking about database indexing. I just tried a "dynamic table" query, and I was able to get a field of type Wikitext to display fine in "details fields", though. I don't know how much testing you did - you may well be seeing some sort of bug in the "dynamic table" handling, but I don't think it's related to the field types per se. Yaron Koren (talk) 12:51, 20 September 2023 (UTC)

Outdated API endpoints?
The list of API endpoints at Extension:Cargo/Other features lists 9 items, but my wiki's /api.php only lists 7 Cargo items. Have "cargofields" and "cargotables" been retired? I tried to use them, but they don't return any result. BrownKDocs (talk) 17:35, 20 September 2023 (UTC)


 * While I'm asking questions about the API-- what is the difference between "cargorecreatedata" and "cargorecreatetables"? It looks like "recreatedata" only works on one table at a time, but are they different beyond that? BrownKDocs (talk) 18:06, 20 September 2023 (UTC)