Hello, as a pretty new Anki user, I’m having trouble knowing if I can make a template out of a note with a specific field type, for example:
I’m pretty bad with the syntax, and haven’t found a full guide to Anki programming language, what I know is just that it’s similar to python.
"Yes, the (Answer where Field= ’Noun’)/{{Grammar}} is
(Answer where Field= ’Stative Verb’) {{Grammar}}
Basically, what I’m looking to find out is if I can generate cards that sentences using varied nouns and varied verbs. Or, I guess, if it’s possible to reference two separate notes in one card?
That is not possible. You might be thinking of notes and cards backwards. You create a note, which has information in its fields. Then Anki uses the instructions in the note type you used – card templates and styling – to make cards from that note.
Card templates are written primarily in HTML and CSS. It’s also possible to include JavaScript.
If you are referring to what looks like Python’s formatted strings – the full guide on replacements can be found here. Everything else, as mentioned above, is just standard HTML, CSS, and JS.
I don’t quite understand what this pseudocode is trying to convey. If you are looking for a way to make cards that have different answers depending on the contents of one of the fields, then it’s quite easy to achieve for cards that only display answers (just use the field as an HTML class and set the CSS display mode for different classes accordingly). For typing cards, this would be trickier, although still doable (will require making a custom typing element and functions; I can provide some code samples, if that’s relevant). There is also a simpler way of making variable typing cards using conditional field replacements (will change the expected answer based on whether a specified field is empty or not, instead of depending on its actual content).
Thank you much for the quick response. I’ll have to give this a pretty thorough attempt later, but I think I’m following.
(To clarify on what I was trying to achieve with the sub code, I was thinking of making a card that essentially inserts a random verb from one of my notes and then inserts a random adjective from a different note, for example)
As @Danika_Dakika said, Anki does not support this. By default, Cards have access only to the information explicitly stored in their Note’s Fields. Accessing other Notes data can be implemented with an add-on, although I’m not aware of any existing ones that have such functionality.
A more practical approach would be to have a duplicate of all the required information from all the Cards in a dedicated Field on each Note and use JS to select a random list item during reviews. This will also ensure that the Cards will work on every platform instead of the desktop app only. In this add-on, you can find a “Fill Choices” command that can be used for such information transfer.
Duplicate information in every card isn’t a good idea. If you already know this information, it’s better to place it in a separate file.
<script> // ***** 251210 show all languages *****************
// gets all data for the index
async function lookupWordAllLangs(index = '') {
try {
// Download once and cache
if (!window._vocabCache) {
const response = await fetch("_book2_note_v.json");
window._vocabCache = await response.json();
}
// Get all languages for a given index
const allLangsData = window._vocabCache?.[index];
if (allLangsData) {
return allLangsData; // {en: {...}, ru: {...}, ...}
}
return null;
} catch (error) {
console.error('ERROR:', error);
return null;
}
}
I can click a button and listen to all the options for 16 languages, but I only store two languages in each card. I think storing everything is redundant unless I always need it, as my text database is about 1.5 megabytes, and if I have 500 cards, that would be a very large deck with just the text information. Even now, I haven’t put all the decks on Anki, as it’s very large—about 100 megabytes each, and 16 languages of words, plus 16 languages of phrases, would be 3 gigabytes.
Aside from the card-design issues – I hope you’re considering that cards with randomly generated fronts don’t make for good memorization material.
The review history for such a card quickly becomes meaningless, since you can’t get both longer intervals for the version of the card you got right and shorter intervals for the version of the card you got wrong, at the same time. There’s also no way to ensure you’ll get the same version of the card on multiple learning steps, or after a lapse when you want to see it again in relearning.