Dynamic Columns/Rows

Dynamic Columns/Rows

I have now learned that if I use {{#if:{{{0|}}}||}}} to determine what's supposed to happen if some parameter is equal to one and what's supposed to happen if it's not equal to one, but I don't know how to use this to create new rows in a table. I need to know how to do this to be able to have the noun table add a row for the count form for masculine nouns when I set some parameter equal to one (let's say "cf"). Now, I only know how to make the code add the count form rather than a dash when the appropriate parameter is defined but this is not satisfactory, because I don't want the count form's row appearing for feminine and neuter nouns. So, could you advise me as to what I should do? I don't think I can just add the code for the new row within one of the parameters of the aforementioned if statements. I tried and the whole template got messed up.

Martin123xyz (talk)17:39, 10 July 2014

Showing and hiding table cells or whole rows with "if" is a bit tricky, because the table formatting code interferes with the code for the "if". Both use |, so things get a little confused. Furthermore, table formatting depends on the presence of line breaks, so if you don't get those right, things also don't work.

For the first problem, the solution is to use the template {{!}} instead of | whenever you want to use a | for a table formatting tag, but inside some other kind of conditional code like "if" or "switch". This makes the code look even harder to understand but at least it works.

For the second problem you have to keep some things in mind when it comes to tables. All the table-specific formatting tags, like and | (new cell) and |- (new row), must be placed at the beginning of a line. They can be placed inside "if", but then that "if" must be placed on the beginning of the line, so that when it is evaluated and replaced with the result text, the table tags will end up on the beginning of the line instead of the "if".

I hope this helps.

CodeCat17:45, 10 July 2014

Thank you for the suggestions - I thought about {{!}} too, after seeing it in the Bulgarian templates, but I'm afraid that the count form still doesn't work.

This is what I put in the general noun template:

{{#if:{{{cf|}}}|style="background:#eff7ff" {{!}} '''count form''' {{!}}{{!}}— {{!}}{{!}} {{#if:{{{cf_pl|}}}|{{l-self|mk|{{{cf_pl}}}|tr=-}}|—}}|}}

This is what I put in the masculine noun template:

-->|cf_pl={{PAGENAME}}а<!--

This is what I put on the page for "маж".

{{mk-decl-noun-m|маж|маж|мажу|cf=1}}

However, no results were produced - everything is the way it was before. I'm presuming that lots of things are terribly wrong with the code I put in the general noun template. How should I fix it? Also, is there any other way to make rows appear and disappear besides these if-statements, if these are not so effective?

Martin123xyz (talk)18:05, 10 July 2014

This is because you are looking to see if one parameter (cf) is empty, but then you display an entirely different parameter (cf_pl). I suggest using just one name, such as "count", for the parameter, as there is no singular form anyway.

Also, don't all masculine nouns ending in a consonant have a count form?

CodeCat18:08, 10 July 2014

Okay, I'll change that and see what happens.

By the way, yes, all masculine nouns ending in a consonant have a count form. However, it's not always derived by simply adding "-а" to the singular stem because sometimes elision is involved. Thus, I will later make another parameter that specifies whether a default count form should be made with the addition of "-а" to the page name or if the provided stem should be used. I haven't done that yet because I was trying to make the dynamic row work first.

Martin123xyz (talk)18:12, 10 July 2014

Okay, I changed it, but the count form went in the wrong place. Look what happened: https://en.wiktionary.org/wiki/%D0%BC%D0%B0%D0%B6#Inflection

Martin123xyz (talk)18:14, 10 July 2014

I made some changes, and it works now.

CodeCat18:22, 10 July 2014

Thank you. It's automatic now, so the row appears even when nothing is defined in the code on the page, generating a count form with "-а" added to the page name by default, but it's okay, I suppose - hopefully incoming editors won't generate any wrong inflection tables because of this. Anyway, I have added an if-statement for the nouns that use another stem than the singular one. I think I can finally start adding inflection tables to all nouns now.

Martin123xyz (talk)18:31, 10 July 2014

Don't forget to check all the entries that already use this template (see Special:WhatLinksHere/Template:mk-decl-noun-m) in case the automatically generated count form is wrong.

CodeCat18:40, 10 July 2014

I didn't know that there were lists of words that use a particular template - how very useful. I had actually wished for something such. Anyway, I shall check them.

Martin123xyz (talk)18:52, 10 July 2014

Every page has such a list. It's on the left.

CodeCat18:52, 10 July 2014

I've checked them - they're fine.

Martin123xyz (talk)08:49, 12 July 2014