Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a card field in anki?

Tags:

anki

In Anki I am trying to hide a third field if it is empty. This field is named Ref. In the styling view of a card, accessed by Edit > Cards, I have the following HTML snippet in the back template:

<a href="{{Ref}}">Link</a>

What I wish to know is how to hide the field if it is empty. There is the possibility to add Javascript to the card field, but there is no element inspector in the program.

like image 213
mr_js Avatar asked Mar 21 '15 13:03

mr_js


People also ask

What is burying card do in Anki?

Bury Card / Note: Hides a card or all of the note's cards from review until the next day. (If you want to unbury cards before then, you can click the “unbury” button on the deck overview screen.) This is useful if you cannot answer the card at the moment or you want to come back to it another time.

How do you turn off tags in Anki?

To remove a tag from a deck, open the deck, then go to the "Edit Deck" screen, using the menu. The deck's tags are shown in the Tags section. On mobile devices, swipe left on a tag to reveal an "X" button. On desktops and laptops, right-click on the tag to reveal the "X" button.


2 Answers

According to the anki manual, you can use conditionals with {{#Field}} ... {{/Field}} or {{^Field}} ... {{/Field}} to test if the field is blank or not. In your case, try something like this:

{{#Link}}
<a href="{{Ref}}">Link</a>
{{/Link}}

I haven't tested it, but it should work.

Edit: It's a bit late, but I realized I mixed up the names of the fields, and the Link field conditionals should have been called Ref:

{{#Ref}}
<a href="{{Ref}}">Link</a>
{{/Ref}}
like image 77
M. Andres Avatar answered Oct 16 '22 20:10

M. Andres


What I ended up doing was the following:

{{#Ref}}<a href="{{Ref}}">Link</a>{{/Ref}}
like image 43
mr_js Avatar answered Oct 16 '22 21:10

mr_js