Manual:Magic words
- Manual:Magic words
Magic words are special keywords within MediaWiki markup that instruct the parser to perform specific actions or insert dynamic content. They are not displayed directly in the rendered page, but instead, their output is substituted based on the current context. Understanding magic words is crucial for advanced editing and customizing your wiki. This guide aims to explain the most commonly used magic words for beginners using MediaWiki 1.40.
What are Magic Words?
Think of magic words as instructions you give to the wiki software. Instead of typing out information directly, you use a magic word that tells the wiki *how* to get that information. This allows for dynamic content, such as the current date, page revision number, or the name of the wiki itself. They greatly enhance the flexibility and utility of your wiki pages.
Categories of Magic Words
Magic words are broadly categorized based on their function:
- Parser Functions: These words manipulate text and perform calculations within the page itself. They are enclosed in `Template:...`. They are powerful for creating templates and dynamic content. See Manual:Parser functions for a complete list.
- Variables: These words represent specific information about the wiki or the current page. They are enclosed in `Template:...`.
- Convertors: These allow the wiki to automatically format numbers, dates, and other data in specific ways. They are enclosed in `Template:...`.
- Page-Related Magic Words: These provide information about the page itself, like its title or the number of revisions. They are enclosed in `Template:...`.
- Category Magic Words: Used for controlling categorization behavior.
- External Data Magic Words: Used for integrating data from external sources (less common in basic use).
Common Magic Words and Examples
Here's a detailed look at some of the most common magic words, along with examples of how to use them. We'll categorize them as described above.
Parser Functions
- `{{#if:condition|then|else}}`: This is a conditional statement. If the `condition` is not empty, `then` is displayed. Otherwise, `else` is displayed.
Example: `{{#if:Manual:Magic words == "Main Page"|Welcome to the main page!|You are not on the main page.}}` This will display "Welcome to the main page!" if the current page is "Main Page", and "You are not on the main page." otherwise.
- `{{#switch:variable|case1|result1|case2|result2|...|default}}`: This allows you to test a variable against multiple cases and return a different result for each case. If no case matches, the `default` result is returned.
Example: `{{#switch:|Main|You are in the main article namespace.|User|You are in the user namespace.|default|You are in another namespace.}}`
- `{{#expr:expression}}`: This evaluates a mathematical expression.
Example: `{{#expr: 2 + 2}}` will display "4". Useful in calculations like Technical analysis or calculating potential profit/loss in Trading strategies.
- `{{#time:format|date}}`: Formats a date and time according to the specified `format`. If `date` is omitted, it defaults to the current date and time. See Manual:Time and date parameters for formatting options.
Example: `{{#time:Y-m-d|now}}` will display the current date in the format "YYYY-MM-DD".
- `{{#titlepart:text|part}}`: Extracts a specific part of a page title. `part` can be `1` (first part), `2` (second part), etc., or `-1` (last part).
Example: If the page title is "Trading Strategy: Moving Averages", `{{#titlepart:Manual:Magic words|1}}` will display "Trading Strategy".
Variables
- `Manual:Magic words`: Displays the current page's title. This is fundamental for creating dynamic links and content. For example, for tracking Market trends.
- ``: Displays the namespace of the current page.
- `binaryoption.wiki`: Displays the name of the wiki server.
- `binaryoption`: Displays the name of the wiki.
- `45267`: Displays the unique ID of the current page.
- `90553`: Displays the revision ID of the current page. Useful for tracking changes and versions of Trading signals.
- `Manual:Magic words`: Displays the full page name, including the namespace.
- `Talk:Manual:Magic words`: Displays the name of the talk page associated with the current page.
Convertors
- `number`: Formats a number with commas or other separators.
Example: `1,234,567` will display "1,234,567". Useful when displaying financial data, like Risk management calculations.
- `⧼string⧽`: Retrieves a localized string from the message catalog. This is important for internationalization.
Page-Related Magic Words
- ``: Returns the name of the subject namespace.
- ``: Returns the name of the article namespace.
- `Template:NUMBEROFACTUALREVISIONS`: Returns the number of factual revisions of the current page.
- `Template:PAGECOUNT`: Returns the number of pages on the wiki.
Category Magic Words
- ``: Specifies the default sort key for pages placed in a category. This ensures pages are sorted correctly within a category. Especially important for categorizing Trading indicators.
- `Template:HIDDENCAT`: Makes a category hidden from view, but still functional for categorization.
Advanced Magic Words & Considerations
While the above covers the most common magic words, several others offer more specialized functionality.
- `{{#var:name}}`: Allows you to define and use custom variables within a template. This is a powerful technique for creating reusable code.
- `{{#set:name=value}}`: Assigns a value to a named variable.
- `{{#get:name}}`: Retrieves the value of a named variable.
- `{{#arraymap:function|array}}`: Applies a function to each element of an array.
- `{{#categorytree:category|depth}}`: Generates a categorized tree view of pages within a specified category. Useful for visualizing the structure of a wiki dealing with complex topics like Financial markets.
- Important Considerations:**
- **Performance:** Excessive use of complex magic words, particularly parser functions, can impact wiki performance. Optimize your templates and avoid unnecessary calculations.
- **Readability:** While magic words are powerful, they can make your wikitext harder to read. Use comments to explain complex logic.
- **Compatibility:** While this guide focuses on MediaWiki 1.40, some magic words might have slightly different behavior in older versions.
- **Security:** Be cautious when using magic words that involve external data, as they could potentially introduce security vulnerabilities.
- **Template Usage:** Magic words are *extremely* powerful within Templates. Templates allow you to encapsulate complex logic and reuse it across multiple pages. For example, a template could dynamically display a table of Bollinger Bands data.
- **Error Handling:** When using `{{#if}}` or `{{#switch}}`, always provide a default case to handle unexpected situations.
- **Documentation:** Always refer to the official MediaWiki documentation for the most up-to-date information on magic words: [1](https://www.mediawiki.org/wiki/Manual:Magic_words)
- **Context Sensitivity:** Some magic words behave differently depending on the context in which they are used (e.g., inside a template vs. directly on a page).
Example: Creating a Dynamic Trading Strategy Page
Let's say we're creating a wiki about trading strategies. We can use magic words to create a dynamic page that displays the current date and the page's revision number:
```wiki
Manual:Magic words
Last updated: {{#time:Y-m-d H:i:s|20250509073416}}. Revision ID: 90553.
This page describes the Trading Strategy. See also: Candlestick patterns, Fibonacci retracement, Elliott Wave Theory, Support and resistance levels, Moving average convergence divergence (MACD), Relative Strength Index (RSI), Stochastic Oscillator, Average True Range (ATR), Ichimoku Cloud, Volume Weighted Average Price (VWAP), Parabolic SAR, Donchian Channels, Heikin Ashi, Keltner Channels, Pivot Points, Bill Williams Fractals, Ichimoku Kinko Hyo, Harmonic Patterns, Renko Charts, Point and Figure Charts, Three Line Break Charts, Market Profile, Order Flow Analysis, Volume Spread Analysis, Wyckoff Method, Gann Theory, Elliott Wave Principle.
Description:
[Add your trading strategy description here] ```
This example demonstrates how to combine `Manual:Magic words`, `20250509073416`, `90553`, and a link to a category to create a useful and informative page. The inclusion of many trading-related links demonstrates internal linking and provides additional resources for the user. This page could then be categorized using `Warning: Default sort key "Trading Strategy" overrides earlier default sort key "key".` to ensure it appears correctly within the "Trading Strategies" category.
Conclusion
Magic words are a powerful tool for customizing and enhancing your MediaWiki wiki. By understanding the different categories and common uses of magic words, you can create dynamic content, automate tasks, and improve the overall user experience. Experiment with different magic words and explore the official documentation to unlock the full potential of MediaWiki. Remember to prioritize readability and performance when using complex magic words. Mastering these features will significantly improve your wiki editing capabilities.
Manual:Templates Manual:Parser functions Help:Formatting Help:Links Special:AllMessages Manual:Category Manual:Time and date parameters Help:Table Manual:Variables Manual:Configuration
Start Trading Now
Sign up at IQ Option (Minimum deposit $10) Open an account at Pocket Option (Minimum deposit $5)
Join Our Community
Subscribe to our Telegram channel @strategybin to receive: ✓ Daily trading signals ✓ Exclusive strategy analysis ✓ Market trend alerts ✓ Educational materials for beginners