Difference between revisions of "Templates"
(Add info about missing templates) |
m (resize image) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | == Wiki Template System == | + | ==Wiki Template System== |
See the [[meta:Help:Template|handbook]] for full details; the local [[Help:Templates]] article covers essentials as does the [[meta:Help:A_quick_guide_to_templates|Quick Guide]] on meta | See the [[meta:Help:Template|handbook]] for full details; the local [[Help:Templates]] article covers essentials as does the [[meta:Help:A_quick_guide_to_templates|Quick Guide]] on meta | ||
See [[wp:Wikipedia:Template_messages]] for info about the templates used in the wikipedia project. | See [[wp:Wikipedia:Template_messages]] for info about the templates used in the wikipedia project. | ||
Line 7: | Line 7: | ||
Unfortunately, despite (old) efforts like '[https://meta.wikimedia.org/wiki/Requests_for_comment/Global_bits_and_pieces Global Bits and Pieces]' or [https://meta.wikimedia.org/wiki/Global-Wiki Global Wiki], [https://www.mediawiki.org/wiki/Global_templates Global Templates], '''MediaWiki software does not come with bundled templates'''. There is no 'package' or 'Starter Kit' of useful templates. Each wiki is left to create their own. Although you ''could'' export and import templates from say mediawiki.org, you would end up with a huge amount of Lua modules and template code that would be overkill for any regular use case. Global Templates was mentioned in the 2020 Community Wishlist under 'miscellaneous' -> 'translate templates' <ref>https://meta.wikimedia.org/wiki/Community_Wishlist_Survey_2021/Miscellaneous/Templates_translation</ref> but it's not an exact match, and likely won't be adopted anyway. Still, there are at least a couple 'Phabricator' issues related to Templates: https://phabricator.wikimedia.org/T121470 https://phabricator.wikimedia.org/T243150 | Unfortunately, despite (old) efforts like '[https://meta.wikimedia.org/wiki/Requests_for_comment/Global_bits_and_pieces Global Bits and Pieces]' or [https://meta.wikimedia.org/wiki/Global-Wiki Global Wiki], [https://www.mediawiki.org/wiki/Global_templates Global Templates], '''MediaWiki software does not come with bundled templates'''. There is no 'package' or 'Starter Kit' of useful templates. Each wiki is left to create their own. Although you ''could'' export and import templates from say mediawiki.org, you would end up with a huge amount of Lua modules and template code that would be overkill for any regular use case. Global Templates was mentioned in the 2020 Community Wishlist under 'miscellaneous' -> 'translate templates' <ref>https://meta.wikimedia.org/wiki/Community_Wishlist_Survey_2021/Miscellaneous/Templates_translation</ref> but it's not an exact match, and likely won't be adopted anyway. Still, there are at least a couple 'Phabricator' issues related to Templates: https://phabricator.wikimedia.org/T121470 https://phabricator.wikimedia.org/T243150 | ||
− | === Types and Examples === | + | ===Types and Examples=== |
− | ==== Presentation and Data Entry ==== | + | ====Presentation and Data Entry==== |
A simple example of this is the [[wp:U2|Wikipedia article on the rock band 'U2']]. This article and all Wikipedia articles about musical groups use a "Infobox musical artist" template so authors can record the basics about the musical artist: Band name, discography, genre, albums etc., AND that information can be systematically formatted for display in the article. | A simple example of this is the [[wp:U2|Wikipedia article on the rock band 'U2']]. This article and all Wikipedia articles about musical groups use a "Infobox musical artist" template so authors can record the basics about the musical artist: Band name, discography, genre, albums etc., AND that information can be systematically formatted for display in the article. | ||
− | ==== Functional Templates ==== | + | |
+ | ====Navigation for a collection of content==== | ||
+ | [[File:Wikitech.wikimedia.org wiki Template Navigation Event Platform.png|alt=example of a Navigation Panel|thumb|example of a Navigation Panel|996.925x996.925px]] | ||
+ | For example, ''[[labsconsole:Template:Navigation_Event_Platform|Navigation Event Platform]] (see right)'' is a template that provides a '''navigation panel''' with a search box plus links to all the most important documentation related to the "Event Platform". It is simple to edit this navigation panel, create sub-sections with headings, add an image for branding, etc. | ||
+ | |||
+ | ====Functional Templates==== | ||
Templates can also be used to include functionality in a page. An example of this is to mark a page, or link to another application systematically based on either a variable, or a "magic word" like PAGENAME More on MediaWiki variables is at [[meta:Help:Variable]] | Templates can also be used to include functionality in a page. An example of this is to mark a page, or link to another application systematically based on either a variable, or a "magic word" like PAGENAME More on MediaWiki variables is at [[meta:Help:Variable]] | ||
− | ==== Static Templates ==== | + | ====Static Templates==== |
Templates can also be used to include static content on a page (kind of like a keyword macro). This is useful when you want to mark a bunch of pages with some common message content, e.g. 'obsolete', '[[:Template:stub|stub]]', 'needs attention' etc.; or perhaps you have a collection of articles that you want to apply a common resource box or navigation to. | Templates can also be used to include static content on a page (kind of like a keyword macro). This is useful when you want to mark a bunch of pages with some common message content, e.g. 'obsolete', '[[:Template:stub|stub]]', 'needs attention' etc.; or perhaps you have a collection of articles that you want to apply a common resource box or navigation to. | ||
− | === Using Templates === | + | ===Using Templates=== |
− | # (optional) create a new page | + | |
− | # insert the template marker in the page content e.g. | + | #(optional) create a new page |
+ | #insert the template marker in the page content e.g. | ||
+ | |||
<nowiki>{{my footer}}</nowiki> would use the 'my footer' template on a page | <nowiki>{{my footer}}</nowiki> would use the 'my footer' template on a page | ||
− | # (optional) save and re-edit the page as needed to fill out a data entry template | + | |
+ | #(optional) save and re-edit the page as needed to fill out a data entry template | ||
Templates that are data entry templates (having multiple parameters) will have (by convention) a 'noinclude' section found in the template that gives an example which makes it a simple matter of copy and paste to begin using that template. | Templates that are data entry templates (having multiple parameters) will have (by convention) a 'noinclude' section found in the template that gives an example which makes it a simple matter of copy and paste to begin using that template. | ||
− | === Available Templates === | + | ===Available Templates=== |
See all templates in the [[Special:Prefixindex|prefix index]] (choose the 'Template' namespace in the select box, then press 'Go') | See all templates in the [[Special:Prefixindex|prefix index]] (choose the 'Template' namespace in the select box, then press 'Go') | ||
− | === Debugging Templates === | + | ===Debugging Templates=== |
You can add <code>action=raw&templates=expand</code> to the end of a page URL to see the raw wikitext as | You can add <code>action=raw&templates=expand</code> to the end of a page URL to see the raw wikitext as | ||
− | === See also === | + | ===See also=== |
The "[[transclusion]]" idea is similar (and shares the same basic syntax) allowing you to include other article content by inclusion. | The "[[transclusion]]" idea is similar (and shares the same basic syntax) allowing you to include other article content by inclusion. | ||
− | == Office Templates | + | ==Office Templates== |
See [[LibreOffice]] | See [[LibreOffice]] | ||
− | == Programming with Template Systems == | + | ==Programming with Template Systems== |
− | * [[wp:Template_engine_(web)]] | + | |
− | * [[wp:Web_template_system]] | + | *[[wp:Template_engine_(web)]] |
+ | *[[wp:Web_template_system]] | ||
+ | |||
There are many templating systems in use throughout technology platforms. In fact, any server-side processing technology like PHP offers a built-in notion of templating for separating your display from your business logic and your data using 'includes'. Carried further, there are major templating sub-systems, template libraries, and/or programming frameworks that utilize a particular templating strategy. | There are many templating systems in use throughout technology platforms. In fact, any server-side processing technology like PHP offers a built-in notion of templating for separating your display from your business logic and your data using 'includes'. Carried further, there are major templating sub-systems, template libraries, and/or programming frameworks that utilize a particular templating strategy. | ||
− | === Smarty === | + | ===Smarty=== |
For PHP programmers, one of the oldest and well-known template systems (aside from building your own using includes) is the [http://smarty.php.net Smarty] system. For a quick overview, see [[wp:Smarty]] There is also a crash course on the Smarty website in addition to the [http://smarty.php.net/manual/en/ documentation] | For PHP programmers, one of the oldest and well-known template systems (aside from building your own using includes) is the [http://smarty.php.net Smarty] system. For a quick overview, see [[wp:Smarty]] There is also a crash course on the Smarty website in addition to the [http://smarty.php.net/manual/en/ documentation] | ||
− | ==== Smarty in CiviCRM ==== | + | ====Smarty in CiviCRM==== |
As of Feb. 2016, Civi uses Smarty v2 | As of Feb. 2016, Civi uses Smarty v2 | ||
Line 53: | Line 63: | ||
− | + | ===Drupal=== | |
− | === Drupal === | ||
Offers a choice of template systems | Offers a choice of template systems | ||
− | === Django === | + | ===Django=== |
Uses the Django Template system | Uses the Django Template system | ||
+ | |||
+ | {{References}} | ||
[[Category:Help]] | [[Category:Help]] | ||
[[Category:Wiki]] | [[Category:Wiki]] |
Latest revision as of 09:40, 20 October 2023
Wiki Template System[edit | edit source]
See the handbook for full details; the local Help:Templates article covers essentials as does the Quick Guide on meta See wp:Wikipedia:Template_messages for info about the templates used in the wikipedia project.
Templates are a system for streamlining the data entry and display formatting of article content.
Unfortunately, despite (old) efforts like 'Global Bits and Pieces' or Global Wiki, Global Templates, MediaWiki software does not come with bundled templates. There is no 'package' or 'Starter Kit' of useful templates. Each wiki is left to create their own. Although you could export and import templates from say mediawiki.org, you would end up with a huge amount of Lua modules and template code that would be overkill for any regular use case. Global Templates was mentioned in the 2020 Community Wishlist under 'miscellaneous' -> 'translate templates' [1] but it's not an exact match, and likely won't be adopted anyway. Still, there are at least a couple 'Phabricator' issues related to Templates: https://phabricator.wikimedia.org/T121470 https://phabricator.wikimedia.org/T243150
Types and Examples[edit | edit source]
Presentation and Data Entry[edit | edit source]
A simple example of this is the Wikipedia article on the rock band 'U2'. This article and all Wikipedia articles about musical groups use a "Infobox musical artist" template so authors can record the basics about the musical artist: Band name, discography, genre, albums etc., AND that information can be systematically formatted for display in the article.
[edit | edit source]
For example, Navigation Event Platform (see right) is a template that provides a navigation panel with a search box plus links to all the most important documentation related to the "Event Platform". It is simple to edit this navigation panel, create sub-sections with headings, add an image for branding, etc.
Functional Templates[edit | edit source]
Templates can also be used to include functionality in a page. An example of this is to mark a page, or link to another application systematically based on either a variable, or a "magic word" like PAGENAME More on MediaWiki variables is at meta:Help:Variable
Static Templates[edit | edit source]
Templates can also be used to include static content on a page (kind of like a keyword macro). This is useful when you want to mark a bunch of pages with some common message content, e.g. 'obsolete', 'stub', 'needs attention' etc.; or perhaps you have a collection of articles that you want to apply a common resource box or navigation to.
Using Templates[edit | edit source]
- (optional) create a new page
- insert the template marker in the page content e.g.
{{my footer}} would use the 'my footer' template on a page
- (optional) save and re-edit the page as needed to fill out a data entry template
Templates that are data entry templates (having multiple parameters) will have (by convention) a 'noinclude' section found in the template that gives an example which makes it a simple matter of copy and paste to begin using that template.
Available Templates[edit | edit source]
See all templates in the prefix index (choose the 'Template' namespace in the select box, then press 'Go')
Debugging Templates[edit | edit source]
You can add action=raw&templates=expand
to the end of a page URL to see the raw wikitext as
See also[edit | edit source]
The "transclusion" idea is similar (and shares the same basic syntax) allowing you to include other article content by inclusion.
Office Templates[edit | edit source]
See LibreOffice
Programming with Template Systems[edit | edit source]
There are many templating systems in use throughout technology platforms. In fact, any server-side processing technology like PHP offers a built-in notion of templating for separating your display from your business logic and your data using 'includes'. Carried further, there are major templating sub-systems, template libraries, and/or programming frameworks that utilize a particular templating strategy.
Smarty[edit | edit source]
For PHP programmers, one of the oldest and well-known template systems (aside from building your own using includes) is the Smarty system. For a quick overview, see wp:Smarty There is also a crash course on the Smarty website in addition to the documentation
Smarty in CiviCRM[edit | edit source]
As of Feb. 2016, Civi uses Smarty v2
Something like this little one-liner can help to generate your Smarty captures if you have a long list of custom variables
php -r 'include ("/var/www/equality-tech.com/www/drupal/sites/all/modules/custom/eqt/eqt.module"); $stack="stats"; $vars = getHaystack($stack); foreach ($vars as $k=>$v) {print "{capture assign=$k}{{$stack}.$k}{/capture}\n";};';
Drupal[edit | edit source]
Offers a choice of template systems
Django[edit | edit source]
Uses the Django Template system