Add Field and Template IDs

AnkiWeb addon 2063785767

Adds IDs to notetype fields and templates, enabling ID-based notetype merging in Anki 23.09+ for notetypes you have authored yourself.
AI-generated summary; may contain mistakes.

note-managementcard-templates

Open on AnkiWeb GitHub Find alternatives

AnkiWeb

Votes
0 (πŸ‘ 0 Β· πŸ‘Ž 0)
Updated
2023-09-08
Anki versions
2.1.66~
License
AGPL-3.0 (from the headers of the Python files)
Virus scan
No ClamAV match A match does not prove malware. No match does not prove that the code is safe.
Languages
Python
Description language
en

Maintenance

abandoned

  • Last update or commit: 2023-09-08 (1150 days before the snapshot).
  • Commits in the last year: 0.
  • Issues: 1 open, 0 closed.
  • Pull requests: 0 open, 0 merged.
  • Median first response: 30 hours (1 answered issues and pull requests).

Will it work on my Anki?

Version branches
Min AnkiMax AnkiUpdated
2.1.66+2023-09-08
History across monthly snapshots

Loading…

Similar addons

Find and Replace in Notetypes

Adds a Browser Edit menu option to find and replace text across one or more card templates by selecting a notetype, aiding add-on and template development.

note-managementcard-templates

14 votes 69% approval πŸ‘ 13 Β· πŸ‘Ž 1 ⭐ 3 Anki 23.12~ Updated 2023-12-27
External Code Editor

Copies card template code to an editable HTML file in collection.media, lets you edit externally, and syncs changes back during review or preview, reloading the card.

card-templatesdeveloper-tools

7 votes 49% approval πŸ‘ 6 Β· πŸ‘Ž 1 ⭐ 5 Anki 23.09~ Updated 2024-01-18
TRDict - Turkish Dictionary

Looks up Turkish definitions, example sentences, and pronunciations from the TDK dictionary, filling single or selected notes via editor/browser buttons, and generating cached pronunciation audio through a template filter.

card-creationcard-templatesdictionary

3 votes 44% approval πŸ‘ 3 Β· πŸ‘Ž 0 ⭐ 1 Anki 23.10.1~ Updated 2023-12-10

Description

Add Field and Template IDs

This add-on for Anki 23.09+ lets you add IDs to notetype fields and templates.

WARNING: Only add IDs to notetypes you have authored yourself!

Full README on GitHub.

README

Add Field and Template IDs

This add-on for Anki 23.09+ lets you add IDs to notetype fields and templates.

WARNING: Only add IDs to notetypes you have authored yourself! (See below.)

Motivation

Before Anki 23.09, if a deck author or consumer had changed the schema of a shared notetype, it became impossible for the deck consumer to receive updates for notes with that notetype.

Example 1

Alice exports a deck D, including note N with notetype NT. Bob imports D. Then Alice adds a new field to NT, and thus to N, and exports the deck again. Bob imports the updated version of D. However, because his version of NT is now conflicting with Alice's new version of NT, Anki cannot update his note N.

Anki 23.09 introduced the concept of merging notetypes. This allows the importing user to receive schema updates for previously imported notetypes, and thus updates for notes with these notetypes.

For this purpose, Anki now adds IDs to new fields and templates. It is also possible to merge notetypes created with earlier releases, which do not have field and template IDs. But then merging is name-based, and thus comes with a few limitations.

With this add-on, you can take advantage of ID-based merging for any notetype.

How Merging Works

Merging one notetype into another means adding any missing fields or templates from the former to the latter. To determine whether one is missing, Anki tries to find a matching one in the second notetype. Two fields or templates match if

  1. their IDs are identical, or
  2. at least one of them does not have an ID, and their names are identical.

Example 2

Alice shared her notetype NT with Bob. It has fields F1 and F2, and template T1. Now, Alice removes field F2 and adds another template, T2. Also, Bob adds the field F3 to his local version. Then he imports Alice's updated version, enabling the Merge notetypes option. His notetype now has fields F1, F2 and F2, and templates T1 and T2.

Furthermore, when merging notetypes, Anki also merges any versions that have been created during previous imports, because there was a conflict and the Merge option had not been enabled.

Adding IDs to Imported Notetypes (don't do it)

If you import a notetype, where both you and the deck sharer used this add-on to add IDs retroactively, no fields or notetype will match, and each one will be duplicated in your local notetype.

To avoid this situation, only add IDs to notetypes you have created yourself, do not add IDs to notetypes you have imported at some point.

Limitations

You may be familiar with schema changes, which alter a notetype in such a way that a one-way sync is required. Roughly, these are the same modifications that prevent you from updating an existing notetype when importing. On the other hand, merging will always be possible, but there are still a few caveats.

The following table provides an overview over what constitutes a schema change, and what prevents you from updating.

Operation Preserve schema Import without merge Import with merge
Modify field / template βœ… βœ… βœ…
Rename field / template βœ… ❌ (1) βœ… (2)
Add field / template ❌ ❌ βœ…
Remove field / template ❌ ❌ βœ… (3)
Reorder fields / templates ❌ ❌ βœ…
Change sort field ❌ βœ… βœ…

1: Importing is still possible if matching is ID-based.
2: If matching is name-based the renamed field will be added as a new one, duplicating the field in the importer's collection.
3: The removed field will not be deleted from the importer's collection.