Difference between revisions of "Templates"

From SuperMemo Help
Jump to navigation Jump to search
(Use templates to give your elements your favorite look)
(Further reading)
 
(23 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Use templates to give your elements your favorite look ==
 
== Use templates to give your elements your favorite look ==
  
A template in SuperMemo is a definition of an element's appearance. Templates are used to create many similarly looking [[Glossary#element | elements]], e.g. with a given color, image, font, etc. The first thing to do with templates is to create a template (i.e. the "common look"). You can do it by first composing an element that looks the way you want other elements to look. This element will contain all [[Glossary#component | components]] that are common to all elements that will be created with the use of the template (e.g. two text fields and one picture components, etc.). All components should have their properties set in the way as in the "common look" (e.g. color, position on the screen, font, etc.). You set the properties of components by using the [[component menu]].
+
A template in SuperMemo is a definition of an [[Glossary:Element|element]]'s appearance. [[Glossary:Template|Templates]] are used to create many similarly looking [[Glossary:Element|elements]], e.g. with a given color, image, font, etc. The first thing to do with [[Glossary:Template|templates]] is to create a template (i.e. the "common look"). You can do it by first composing an [[Glossary:Element|element]] that looks the way you want other elements to look. This [[Glossary:Element|element]] will contain all [[Glossary:Component|components]] that are common to all elements that will be created with the use of the [[Glossary:Template|template]] (e.g. two text fields and one picture component, etc.). All [[Glossary:Component|components]] should have their properties set in the way as in the "common look" (e.g. color, position on the screen, font, etc.). You set the properties of [[Glossary:Component|components]] by using the [[component menu]].
  
After creating the element with the desired look, you can use [[Element menu#Save as template | Template : Save as template]] on the [[element menu]] (this menu opens with [[Keyboard shortcuts | ''Alt+F10'']] or with a right-click over the [[element toolbar]]).
+
After creating the [[Glossary:Element|element]] with the desired look, you can use '''[[Element menu#Template|Template]] : [[Element menu#Save as template|Save as template]]''' on the [[element menu]] (this menu opens with [[Keyboard shortcuts | ''Alt+F10'']] or with a right-click over the [[navigation bar]]).
  
Saving templates with '''Save as template''' makes it possible to keep a "gallery of looks" for future use. This gallery is called the [[Registry window | template registry]]. You can save any element as a template. If you want particular texts, sounds or pictures to be associated with the template, use '''Template : Save with objects'''. '''Save as template''' does not save objects associated with components. For example, it will save the position and color of a text component, but it will not save the text (e.g. "''US Constitution''").
+
Saving templates with '''[[Element menu#Save as template|Save as template]]''' makes it possible to keep a "gallery of looks" for future use. This gallery is called the template [[Glossary:Registry|registry]]. You can save any [[Glossary:Element|element]] as a [[Glossary:Template|template]]. If you want particular texts, sounds or pictures to be associated with the [[Glossary:Template|template]], use '''[[Element menu#Template|Template]] : Save with objects'''. '''[[Element menu#Save as template|Save as template]]''' does not save objects associated with [[Glossary:Component|components]]. For example, it will save the position and color of a text [[Glossary:Component|component]], but it will not save the text (e.g. "''US Constitution''").
  
The template [[Glossary#registry | registry]] (i.e. the gallery of templates) can be viewed with '''[[Search menu | Search]] : Templates''' on the [[main menu]].
+
The template [[Glossary:Registry|registry]] (i.e. the gallery of [[Glossary:Template|templates]]) can be viewed with '''[[Search menu|Search]] : [[Search menu#Templates|Templates]]''' on the [[main menu]].
  
If you want a template to be used by default each time you choose '''Add new''' (or when you add topics with ''Alt+N'' or ''Ctrl+Alt+N''), use '''[[Element menu#Save as default | Template : Save as default]]''' (''Ctrl+Alt+M'').''' Save as default''' will save the template in the same way as '''Save as template''' but will also make this template the default template for the currently used [[Categories | category]]. Only elements of the same type will be affected. This means that if you save an item template, new items will change their appearance, but the appearance of topics will remain the same. The appearance of previously added items or topics will not be affected (unless you save the new default template under an already used name).
+
If you want a [[Glossary:Template|template]] to be used by default each time you choose '''Add new''' (or when you add [[Glossary:Topic|topics]] with ''Alt+N'' or ''Ctrl+N''), use '''[[Element menu#Template|Template]] : [[Element menu#Save as default|Save as default]]'''. '''[[Element menu#Save as default|Save as default]]''' will save the [[Glossary:Template|template]] in the same way as '''[[Element menu#Save as template|Save as template]]''' but will also make this [[Glossary:Template|template]] the default one for the currently used [[Glossary:Concept_group|concept group]]. Only [[Glossary:Element|elements]] of the same type will be affected. This means that if you save an item [[Glossary:Template|template]], new [[Glossary:Item|items]] will change their appearance, but the appearance of [[Glossary:Topic|topics]] will remain the same. The appearance of previously added [[Glossary:Item|items]] or [[Glossary:Topic|topics]] will not be affected (unless you save the new default [[Glossary:Template|template]] under an already used name).
  
To give an element a selected look, apply the appropriate template to this element. Any template can be selected from the template registry and applied to any element with [[Element menu#Apply template | '''Template : Apply template''']] (''Shift+Ctrl+M''). After you choose a template in the registry, click the '''Accept''' button at the bottom of the [[Registry window | template registry window]] (or press ''Enter''). Applying a template does not overwrite the "old look". You can remove the applied template by choosing '''Template : Detach template'''.
+
To give an [[Glossary:Element|element]] a selected look, apply the appropriate [[Glossary:Template|template]] to this element. Any [[Glossary:Template|template]] can be selected from the template [[Glossary:Registry|registry]] and applied to any [[Glossary:Element|element]] with '''[[Element menu#Template|Template]] : [[Element menu#Apply template|Apply template]]''' (''Shift+Ctrl+M''). After you choose a [[Glossary:Template|template]] in the [[Glossary:Registry|registry]]], click the '''Accept''' button at the bottom of the template [[registry window]] (or press ''Enter''). Applying a [[Glossary:Template|template]] does not overwrite the "old look". You can remove the applied template by choosing '''[[Element menu#Template|Template]] : [[Element menu#Detach template|Detach template]]'''.
  
 
=== Using fonts with a template ===
 
=== Using fonts with a template ===
  
To associate a font with a text component in a template, use '''Text : Font : New font''', '''Text : Font : Link font''' (''Shift+Ctrl+F'') or '''Text : Font : Edit font''' on the [[component menu]] (see more: [[Fonts tab in Options | Font options]]). If you want to change fonts globally in a set of existing items, you need to use [[Using text components | plain text components]]. This comes from a difference between [[Using text components | plain text components]] and HTML text components in the way they interpret the font associated with the template:
+
To associate a font with a text [[Glossary:Component|component]] in a [[Glossary:Template|template]], use '''[[Component menu#Text|Text]] : Font : New font''', '''[[Component menu#Text|Text]] : Font : Link font''' (''Shift+Ctrl+F'') or '''[[Component menu#Text|Text]] : Font : Edit font''' on the [[component menu]] (see more: [[Fonts tab in Options|Font options]]). If you want to change fonts globally in a set of existing [[Glossary:Item|items]], you need to use [[Using text components|plain text components]]. This comes from a difference between [[Using text components|plain text components]] and [[HTML component|HTML text components]] in the way they interpret the font associated with the [[Glossary:Template|template]]:
  
* '''plain text components''': if you associate a font with a plain text component in a template (e.g. as in the ''Classic'' template), all texts used by the component in all elements that use the template will use the associated font. For example, if you choose a ''Greek'' font for such a template, all elements using this template will display in ''Greek''
+
* '''plain text components''': if you associate a font with a plain text [[Glossary:Component|component]] in a [[Glossary:Template|template]] (e.g. as in the ''Classic'' template), all texts used by the component in all [[Glossary:Element|elements]] that use the template will use the associated font. For example, if you choose a ''Greek'' font for such a [[Glossary:Template|template]], all [[Glossary:Element|elements]] using this template will display in ''Greek''
* '''HTML text components''': if you associate a font with an HTML component in a template (e.g. as in the ''Item'' template), the font will be applied only when you begin writing the text. For example, if you choose a ''Greek'' font for such a template, all new texts typed into such a template will begin to show in ''Greek''; however, old texts will not be affected. You will be able to change the font while typing the text and thus use ''Greek'' at the beginning of your text and, for example, ''Cyrillic'' towards its end. See: [[Using fonts | Fonts in SuperMemo]]
+
* '''HTML text components''': if you associate a font with an [[HTML component]] in a [[Glossary:Template|template]] (e.g. as in the ''Item'' template), the font will be applied only when you begin writing the text. For example, if you choose a ''Greek'' font for such a [[Glossary:Template|template]], all new texts typed into such a template will begin to show in ''Greek''; however, old texts will not be affected. You will be able to change the font while typing the text and thus use ''Greek'' at the beginning of your text and, for example, ''Cyrillic'' towards its end. See: [[Using fonts|Fonts in SuperMemo]]
  
=== Category templates help you switch fast between different templates for different learning subjects ===
+
=== Concept templates help you switch fast between different templates for different learning subjects ===
  
If you want to associate a template with a given subject, e.g. ''Chemistry'', you can use category templates. You will need the following before you begin:
+
If you want to associate a [[Glossary:Template|template]] with a given subject, e.g. ''Chemistry'', you can use concept templates. You will need the following before you begin:
  
# Define a template as described above (e.g. by reworking an existing template and saving it with [[Element menu#Save as default | '''Template : Save as default''']] or with ''Ctrl+Alt+M'')
+
# Define a [[Glossary:Template|template]] as described above (e.g. by reworking an existing template and saving it with '''[[Element menu#Template|Template]] : [[Element menu#Save as default|Save as default]]''')
# Define a new category or redefine an existing category. When you create a new collection, you begin with a single category whose name is the same as the name of the collection (see: [[Categories | Using categories]])
+
# Create a new [[Glossary:Concept|concept]] or redefine an existing one. When you create a new [[Glossary:Collection|collection]], you begin with a single [[Glossary:Concept|concept]] whose name is the same as the name of the collection (see: [[Concepts|Using concepts]])
  
To define a category template do as follows:
+
To define a concept template do as follows:
  
# Choose '''[[Search menu | Search]] : [[Categories]]''' on the [[main menu]] (if you are not at the [[Levels | professional level]], switch the level, e.g. with ''Ctrl+Alt+F12'')
+
# Choose '''[[Search menu|Search]] : [[Search menu#Concepts|Concepts]]''' on the [[main menu]] (if you are not at the '''Professional''' [[Glossary:Level|level]], switch the level, e.g. with ''Ctrl+Alt+F12'')
# Select the category (e.g. by typing its name at the top of the category registry window)
+
# Select the concept (e.g. by typing its name at the top of the concept [[registry window]])
# Click the '''Template''' button
+
# Click the '''Item/Topic template''' button
# Choose the template from the template registry (e.g. by typing its name at the top of the template registry window)
+
# Choose the [[Glossary:Template|template]] from the template [[Glossary:Registry|registry]] (e.g. by typing its name at the top of the template [[registry window]])
# Click '''Accept''' (at the bottom of the template registry window)
+
# Click '''Accept''' (at the bottom of the template [[registry window]])
# Close the category registry window
+
# Close the concept [[registry window]]
  
The above will make sure that your template is used each time you choose [[add new]] or press [[Keyboard shortcuts | ''Alt+A'']] as long as your [[Glossary#category | category]] is selected as the current category in the [[Toolbar dock | category combo-box]].
+
The above will make sure that your [[Glossary:Template|template]] is used each time you choose '''[[Add new]]''' or press [[Keyboard shortcuts | ''Alt+A'']] as long as your [[Glossary#Concept_group|concept group]] is selected as the current one in the [[navigation bar]].
  
 
=== You can apply a template to many elements at once ===
 
=== You can apply a template to many elements at once ===
  
You can change the look of many elements at the same time. If your elements use a given template, go to one of these elements and simply redefine the template. If your elements use different templates or use no template at all, you can apply a template to all of them by choosing '''[[File menu | File]] : Process collection : Template : Apply template''' from the [[main menu]], '''[[Processing multiple elements (Process collection/branch/browser) | Process branch]] : Template : Apply template''' in the [[contents window]], or '''[[Processing multiple elements (Process collection/branch/browser) | Process browser]] : Template : Apply template''' in the [[browser]]
+
You can change the look of many [[Glossary:Element|elements]] at the same time. If your [[Glossary:Element|elements]] use a given [[Glossary:Template|template]], go to one of these elements and simply redefine the template. If your [[Glossary:Element|elements]] use different [[Glossary:Template|templates]] or use no template at all, you can apply a template to all of them by choosing '''[[File menu|File]] : [[File menu#Process collection>|Process collection>]] : [[Subset operations#Template|Template]] : Apply template''' from the [[main menu]], '''[[Subset operations|Process branch>]] : [[Subset operations#Template|Template]] : Apply template''' in the [[Contents|'''Contents''' window]], or '''[[Subset operations|Process browser>]] : [[Subset operations#Template|Template]] : Apply template''' in the [[browser]].
  
 
== Template operations reference  ==
 
== Template operations reference  ==
  
Here is the summary of template operations on the '''Template''' submenu of the [[Element menu]] (use ''Alt+F10'' to open this menu or right-click over the empty element area or over the [[Element toolbar]]):  
+
Here is the summary of template operations on the '''[[Element menu#Template|Template]]''' submenu of the [[element menu]] (use ''Alt+F10'' to open this menu or right-click over the empty element area or over the [[navigation bar]]):  
  
*'''<span id="Save_as_template">Save as template</span>''' - save the currently displayed element as a template. This makes it possible to use the appearance of the element in other elements. Template objects such as pictures or texts are not saved with the template  
+
*'''<span id="Save_as_template">Save as template</span>''' - save the currently displayed [[Glossary:Element|element]] as a [[Glossary:Template|template]]. This makes it possible to use the appearance of the element in other elements. Template objects such as pictures or texts are not saved with the template  
*'''<span id="Save_as_default">Save as default</span>''' - save the current element as a template and make it the default template in the currently selected category. Choosing ''Ctrl+Alt+M'' is the fastest way to make sure that all new items added to the [[Categories|current category]] look similar. '''Save as default''' does not save template objects. If you would like to save objects in the default template, use '''Save with objects''' and then select this template as the default template for the current category ('''[[Search menu|Search]]&nbsp;: [[Categories]]''')  
+
*'''<span id="Save_as_default">Save as default</span>''' - save the current [[Glossary:Element|element]] as a [[Glossary:Template|template]] and make it the default template in the currently selected [[Glossary:Concept_group|concept group]]. '''Save as default''' does not save template objects. If you would like to save objects in the default [[Glossary:Template|template]], use '''Save with objects''' and then select this template as the default template for the current [[Glossary:Concept_group|concept group]] ('''[[Search menu|Search]] : [[Search menu#Concepts|Concepts]]''')  
*'''Save with objects''' - save the currently displayed element as a template together with template objects. The saved template will include references to texts, pictures, sounds and other objects associated with the element. For example, if your question begins with "geography: ", this text will become part of the template and will show up in newly created elements using that template  
+
*'''Save with objects''' - save the currently displayed [[Glossary:Element|element]] as a [[Glossary:Template|template]] together with template objects. The saved template will include references to texts, pictures, sounds and other objects associated with the element. For example, if your question begins with "geography: ", this text will become part of the [[Glossary:Template|template]] and will show up in newly created [[Glossary:Element|elements]] using that template  
*'''<span id="Apply_template">Apply template</span>''' (''Shift+Ctrl+M'') - use a selected template from the template registry to modify the look of the element. The original look will remain untouched as the ''template source'' and can be inspected with '''Template&nbsp;: View source''' or restored with '''Template&nbsp;: Detach template'''. When using '''Apply template''', after selecting the template in the template registry, you should click the button '''Accept''', double-click the template or press ''Enter''. After using '''Template&nbsp;: Apply template''', the template source can be overwritten with'''Template&nbsp;: Impose template'''. In applying a template, SuperMemo transfers all matching registry objects (e.g. texts, images, etc.) from the source template to the applied template. Source components that do not find their match in the applied template will become invisible or will show up unchanged (depending on the settings in the '''Template&nbsp;: [[Element menu#template_flags|Template flags]]''' submenu)  
+
*'''<span id="Apply_template">Apply template</span>''' (''Shift+Ctrl+M'') - use a selected [[Glossary:Template|template]] from the template [[Glossary:Registry|registry]] to modify the look of the [[Glossary:Element|element]]. The original look will remain untouched as the ''template source'' and can be inspected with '''[[Element menu#Template|Template]] : View source''' or restored with '''[[Element menu#Template|Template]] : Detach template'''. When using '''Apply template''', after selecting the [[Glossary:Template|template]] in the template [[Glossary:Registry|registry]], you should click the button '''Accept''', double-click the template or press ''Enter''. After using '''[[Element menu#Template|Template]] : [[#Apply template|Apply template]]''', the template source can be overwritten with'''[[Element menu#Template|Template]] : [[#Impose template|Impose template]]'''. In applying a [[Glossary:Template|template]], SuperMemo transfers all matching registry objects (e.g. texts, images, etc.) from the source template to the applied template. Source [[Glossary:Component|components]] that do not find their match in the applied [[Glossary:Template|template]] will become invisible or will show up unchanged (depending on the settings in the '''[[Element menu#Template|Template]] : [[Element menu#template_flags|Template flags]]''' submenu)  
*'''Replace with template''' - replace the current template source with a new template. The original look of the element will be lost. '''Replace with template''' is equivalent to '''Apply template''' and '''Impose template''' run in succession. The template is not detached and all its changes will be reflected in the looks of other elements  
+
*'''Replace with template''' - replace the current template source with a new [[Glossary:Template|template]]. The original look of the [[Glossary:Element|element]] will be lost. '''Replace with template''' is equivalent to '''Apply template''' and '''Impose template''' run in succession. The [[Glossary:Template|template]] is not detached and all its changes will be reflected in the looks of other [[Glossary:Element|elements]]
*'''Detach template''' - restore the original look of the element from before the time the template had been applied with '''Apply template'''. The element will become template-less until a new template is applied. Changes to the element's appearance will affect no other elements or templates. After '''Detach template''', '''View source''' will have no effect  
+
*'''Detach template''' - restore the original look of the [[Glossary:Element|element]] from before the time the [[Glossary:Template|template]] had been applied with '''[[#Apply template|Apply template]]'''. The [[Glossary:Element|element]] will become template-less until a new [[Glossary:Template|template]] is applied. Changes to the element's appearance will affect no other [[Glossary:Element|elements]] or [[Glossary:Template|templates]]. After '''Detach template''', '''View source''' will have no effect  
*'''<span id="Impose_template">Impose template</span>''' (''Shift+Ctrl+F2'') - overwrite the source template (i.e. the original look that came with the element) with the currently applied template (i.e. the look superimposed on the original look with a template). After '''Impose template''' (that will make source equal to template, i.e. write the template over the original look), '''View source''' will have no effect as the source template will be the same as the applied template. Answer ''Yes'' to ''Detach template?'' if you want to detach the template (i.e. remove the connection between the element and the template) without changing the look of the element (i.e. keep the template's look but remove the connection - that makes the source look like the template but be connected to no template). This will ensure that changes to the element will not affect the detached global template (i.e. because there will be no link, the element has no template, so changes to the element stay local)  
+
*'''<span id="Impose_template">Impose template</span>''' (''Shift+Ctrl+F2'') - overwrite the source template (i.e. the original look that came with the [[Glossary:Element|element]]) with the currently applied [[Glossary:Template|template]] (i.e. the look superimposed on the original look with a template). After '''Impose template''' (that will make source equal to template, i.e. write the template over the original look), '''View source''' will have no effect as the source template will be the same as the applied template. Answer ''Yes'' to ''Detach template?'' if you want to detach the template (i.e. remove the connection between the [[Glossary:Element|element]] and the [[Glossary:Template|template]]) without changing the look of the element (i.e. keep the template's look but remove the connection - that makes the source look like the template but be connected to no template). This will ensure that changes to the [[Glossary:Element|element]] will not affect the detached global [[Glossary:Template|template]] (i.e. because there will be no link, the element has no template, so changes to the element stay local)  
*'''Add template''' - add components from a selected template to the currently displayed element  
+
*'''Add template''' - add [[Glossary:Component|components]] from a selected [[Glossary:Template|template]] to the currently displayed [[Glossary:Element|element]]
*'''View source''' (''Ctrl+Shift+U'') - view the source template of the current element. The source template is the original look of the element before any template was applied with '''Template&nbsp;: Apply template'''  
+
*'''View source''' (''Ctrl+Shift+U'') - view the source template of the current [[Glossary:Template|element]]. The source [[Glossary:Template|template]] is the original look of the element before any template was applied with '''[[Element menu#Template|Template]] : [[#Apply template|Apply template]]'''  
*'''Save to file''' - save the current element as a template file. This file can later be loaded into another collection with '''Template&nbsp;: Load from file'''. You can view template files with any text editor. Note that these files do not store registry objects but only references to appropriate files. This way a template file is useful only as long as the source collection remains in its original location on the disk. Once it is moved, references in the template file will be ignored  
+
*'''Save to file''' - save the current [[Glossary:Element|element]] as a template file. This file can later be loaded into another [[Glossary:Collection|collection]] with '''[[Element menu#Template|Template]] : Load from file'''. You can view template files with any text editor. Note that these files do not store registry objects but only references to appropriate files. This way a template file is useful only as long as the source [[Glossary:Collection|collection]] remains in its original location on the disk. Once it is moved, references in the template file will be ignored  
*'''Load from file''' - load a template file saved with '''Template&nbsp;: Save to file'''. Loading template file deletes all components and creates new components specified in the template  
+
*'''Load from file''' - load a [[Glossary:Template|template]] file saved with '''[[Element menu#Template|Template]] : Save to file'''. Loading template file deletes all [[Glossary:Component|components]] and creates new components specified in the [[Glossary:Template|template]]
*'''Copy template''' - copy the currently used template to the clipboard  
+
*'''Copy template''' - copy the currently used [[Glossary:Template|template]] to the clipboard  
*'''Paste template''' - paste the template from the clipboard (currently displayed template will be overwritten)  
+
*'''Paste template''' - paste the [[Glossary:Template|template]] from the clipboard (currently displayed template will be overwritten)  
*'''Template flags''' - advanced users may want to determine in detail how templates are interpreted where the template does not match the source. Template flags determine which&nbsp;unmatching components&nbsp;will be&nbsp;displayed&nbsp;(for details see:&nbsp;[[Element menu#template_flags|'''Template flags''']])
+
*'''Template flags''' - advanced users may want to determine in detail how [[Glossary:Template|templates]] are interpreted where the template does not match the source. Template flags determine which unmatching [[Glossary:Component|components]] will be displayed (for details see: [[Element menu#template_flags|'''Template flags''']])
  
 
== Advanced template operations ==
 
== Advanced template operations ==
Line 65: Line 65:
 
=== Adding components to a group of existing elements ===
 
=== Adding components to a group of existing elements ===
  
If you want to add new components to a group of elements, use '''Add template''' on the [[main menu]], in the [[contents window]] or in the [[browser]]. This will retain the old components and add new components from the added template. '''Add to template''' is similar to '''Apply template''' but the contents of the new template is simply superimposed over the old template
+
If you want to add new [[Glossary:Component|components]] to a group of [[Glossary:Element|elements]], use '''Add template''' on the [[main menu]], in the [[Contents|'''Contents''' window]] or in the [[browser]]. This will retain the old [[Glossary:Component|components]] and add new components from the added [[Glossary:Template|template]]. '''Add to template''' is similar to '''Apply template''' but the contents of the new [[Glossary:Template|template]] is simply superimposed over the old template
  
 
=== Transferring templates between collections ===
 
=== Transferring templates between collections ===
  
If you want to transfer templates (or single elements) between different [[Glossary#collection | collections]], use '''Template : Save to file''' and '''Template : Load from file'''. You can also use '''Edit : Copy element''' with '''Edit : Paste template''' and '''Edit : Paste element''' to transfer templates and elements within a collection or between different collections using the clipboard
+
If you want to transfer [[Glossary:Template|templates]] (or single [[Glossary:Element|elements]]) between different [[Glossary#Collection|collections]], use '''[[Element menu#Template|Template]] : Save to file''' and '''[[Element menu#Template|Template]] : Load from file'''. You can also use '''[[Element menu#Edit|Edit]] : Copy element''' with '''[[Element menu#Edit|Edit]] : Paste template''' and '''[[Element menu#Edit|Edit]] : Paste element''' to transfer [[Glossary:Template|templates]] and [[Glossary:Element|elements]] within a [[Glossary:Collection|collection]] or between different collections using the clipboard
  
 
== Further reading ==
 
== Further reading ==
  
[http://supermemo.com/help/faq/templates.htm FAQ: Templates in SuperMemo]
+
[https://www.super-memory.com/archive/help16/faq/templates.htm FAQ: Templates in SuperMemo]
 +
 
 +
== Video example ==
 +
 
 +
The example shows how to save a template with a chosen stylesheet that defines a specific font:
 +
 
 +
{{#ev:youtube|A7hhUh9h0fQ}}

Latest revision as of 21:58, 9 August 2019

Use templates to give your elements your favorite look

A template in SuperMemo is a definition of an element's appearance. Templates are used to create many similarly looking elements, e.g. with a given color, image, font, etc. The first thing to do with templates is to create a template (i.e. the "common look"). You can do it by first composing an element that looks the way you want other elements to look. This element will contain all components that are common to all elements that will be created with the use of the template (e.g. two text fields and one picture component, etc.). All components should have their properties set in the way as in the "common look" (e.g. color, position on the screen, font, etc.). You set the properties of components by using the component menu.

After creating the element with the desired look, you can use Template : Save as template on the element menu (this menu opens with Alt+F10 or with a right-click over the navigation bar).

Saving templates with Save as template makes it possible to keep a "gallery of looks" for future use. This gallery is called the template registry. You can save any element as a template. If you want particular texts, sounds or pictures to be associated with the template, use Template : Save with objects. Save as template does not save objects associated with components. For example, it will save the position and color of a text component, but it will not save the text (e.g. "US Constitution").

The template registry (i.e. the gallery of templates) can be viewed with Search : Templates on the main menu.

If you want a template to be used by default each time you choose Add new (or when you add topics with Alt+N or Ctrl+N), use Template : Save as default. Save as default will save the template in the same way as Save as template but will also make this template the default one for the currently used concept group. Only elements of the same type will be affected. This means that if you save an item template, new items will change their appearance, but the appearance of topics will remain the same. The appearance of previously added items or topics will not be affected (unless you save the new default template under an already used name).

To give an element a selected look, apply the appropriate template to this element. Any template can be selected from the template registry and applied to any element with Template : Apply template (Shift+Ctrl+M). After you choose a template in the registry], click the Accept button at the bottom of the template registry window (or press Enter). Applying a template does not overwrite the "old look". You can remove the applied template by choosing Template : Detach template.

Using fonts with a template

To associate a font with a text component in a template, use Text : Font : New font, Text : Font : Link font (Shift+Ctrl+F) or Text : Font : Edit font on the component menu (see more: Font options). If you want to change fonts globally in a set of existing items, you need to use plain text components. This comes from a difference between plain text components and HTML text components in the way they interpret the font associated with the template:

  • plain text components: if you associate a font with a plain text component in a template (e.g. as in the Classic template), all texts used by the component in all elements that use the template will use the associated font. For example, if you choose a Greek font for such a template, all elements using this template will display in Greek
  • HTML text components: if you associate a font with an HTML component in a template (e.g. as in the Item template), the font will be applied only when you begin writing the text. For example, if you choose a Greek font for such a template, all new texts typed into such a template will begin to show in Greek; however, old texts will not be affected. You will be able to change the font while typing the text and thus use Greek at the beginning of your text and, for example, Cyrillic towards its end. See: Fonts in SuperMemo

Concept templates help you switch fast between different templates for different learning subjects

If you want to associate a template with a given subject, e.g. Chemistry, you can use concept templates. You will need the following before you begin:

  1. Define a template as described above (e.g. by reworking an existing template and saving it with Template : Save as default)
  2. Create a new concept or redefine an existing one. When you create a new collection, you begin with a single concept whose name is the same as the name of the collection (see: Using concepts)

To define a concept template do as follows:

  1. Choose Search : Concepts on the main menu (if you are not at the Professional level, switch the level, e.g. with Ctrl+Alt+F12)
  2. Select the concept (e.g. by typing its name at the top of the concept registry window)
  3. Click the Item/Topic template button
  4. Choose the template from the template registry (e.g. by typing its name at the top of the template registry window)
  5. Click Accept (at the bottom of the template registry window)
  6. Close the concept registry window

The above will make sure that your template is used each time you choose Add new or press Alt+A as long as your concept group is selected as the current one in the navigation bar.

You can apply a template to many elements at once

You can change the look of many elements at the same time. If your elements use a given template, go to one of these elements and simply redefine the template. If your elements use different templates or use no template at all, you can apply a template to all of them by choosing File : Process collection> : Template : Apply template from the main menu, Process branch> : Template : Apply template in the Contents window, or Process browser> : Template : Apply template in the browser.

Template operations reference

Here is the summary of template operations on the Template submenu of the element menu (use Alt+F10 to open this menu or right-click over the empty element area or over the navigation bar):

  • Save as template - save the currently displayed element as a template. This makes it possible to use the appearance of the element in other elements. Template objects such as pictures or texts are not saved with the template
  • Save as default - save the current element as a template and make it the default template in the currently selected concept group. Save as default does not save template objects. If you would like to save objects in the default template, use Save with objects and then select this template as the default template for the current concept group (Search : Concepts)
  • Save with objects - save the currently displayed element as a template together with template objects. The saved template will include references to texts, pictures, sounds and other objects associated with the element. For example, if your question begins with "geography: ", this text will become part of the template and will show up in newly created elements using that template
  • Apply template (Shift+Ctrl+M) - use a selected template from the template registry to modify the look of the element. The original look will remain untouched as the template source and can be inspected with Template : View source or restored with Template : Detach template. When using Apply template, after selecting the template in the template registry, you should click the button Accept, double-click the template or press Enter. After using Template : Apply template, the template source can be overwritten withTemplate : Impose template. In applying a template, SuperMemo transfers all matching registry objects (e.g. texts, images, etc.) from the source template to the applied template. Source components that do not find their match in the applied template will become invisible or will show up unchanged (depending on the settings in the Template : Template flags submenu)
  • Replace with template - replace the current template source with a new template. The original look of the element will be lost. Replace with template is equivalent to Apply template and Impose template run in succession. The template is not detached and all its changes will be reflected in the looks of other elements
  • Detach template - restore the original look of the element from before the time the template had been applied with Apply template. The element will become template-less until a new template is applied. Changes to the element's appearance will affect no other elements or templates. After Detach template, View source will have no effect
  • Impose template (Shift+Ctrl+F2) - overwrite the source template (i.e. the original look that came with the element) with the currently applied template (i.e. the look superimposed on the original look with a template). After Impose template (that will make source equal to template, i.e. write the template over the original look), View source will have no effect as the source template will be the same as the applied template. Answer Yes to Detach template? if you want to detach the template (i.e. remove the connection between the element and the template) without changing the look of the element (i.e. keep the template's look but remove the connection - that makes the source look like the template but be connected to no template). This will ensure that changes to the element will not affect the detached global template (i.e. because there will be no link, the element has no template, so changes to the element stay local)
  • Add template - add components from a selected template to the currently displayed element
  • View source (Ctrl+Shift+U) - view the source template of the current element. The source template is the original look of the element before any template was applied with Template : Apply template
  • Save to file - save the current element as a template file. This file can later be loaded into another collection with Template : Load from file. You can view template files with any text editor. Note that these files do not store registry objects but only references to appropriate files. This way a template file is useful only as long as the source collection remains in its original location on the disk. Once it is moved, references in the template file will be ignored
  • Load from file - load a template file saved with Template : Save to file. Loading template file deletes all components and creates new components specified in the template
  • Copy template - copy the currently used template to the clipboard
  • Paste template - paste the template from the clipboard (currently displayed template will be overwritten)
  • Template flags - advanced users may want to determine in detail how templates are interpreted where the template does not match the source. Template flags determine which unmatching components will be displayed (for details see: Template flags)

Advanced template operations

Adding components to a group of existing elements

If you want to add new components to a group of elements, use Add template on the main menu, in the Contents window or in the browser. This will retain the old components and add new components from the added template. Add to template is similar to Apply template but the contents of the new template is simply superimposed over the old template

Transferring templates between collections

If you want to transfer templates (or single elements) between different collections, use Template : Save to file and Template : Load from file. You can also use Edit : Copy element with Edit : Paste template and Edit : Paste element to transfer templates and elements within a collection or between different collections using the clipboard

Further reading

FAQ: Templates in SuperMemo

Video example

The example shows how to save a template with a chosen stylesheet that defines a specific font: