%TOC\{depth="4"\}% %STARTINCLUDE% # <a name="TWikiVariables_Examples"> TWikiVariables Examples </a> ## <a name="Bullet_list_showing_topic_name_a"> Bullet list showing topic name and summary </a> **Write this:** <code>%SEARCH\{ "FAQ" scope="topic" web="TWiki" nosearch="on" nototal="on" header=" \* \*Topic: Summary:\*" format=" \* [[$web.$topic]]: $summary" \}%</code> **To get this:** %SEARCH\{ "FAQ" scope="topic" web="TWiki" nosearch="on" nototal="on" header=" \* \*Topic: Summary:\*" format=" \* [[Webtopic]]: $summary" \}% ## <a name="Table_with_form_field_values_of_"> Table with form field values of topics with a form </a> **Write this:** <code>| \*Topic:\* | \*OperatingSystem:\* | \*OsVersion:\* |</code><br /><code>%SEARCH\{ "[T]opicClassification.\*?value=\\"[P]ublicFAQ\\"" scope="text" regex="on" nosearch="on" nototal="on" format="| [[$topic]] | $formfield([[OperatingSystem]]) | $formfield([[OsVersion]]) |" \}%</code> **To get this:** _(simulated)_ <table border="1" cellpadding="1" cellspacing="0"> <tr> <th bgcolor="#99CCCC"><strong>Topic:</strong></th> <th bgcolor="#99CCCC"><strong>OperatingSystem:</strong></th> <th bgcolor="#99CCCC"><strong>OsVersion:</strong></th> </tr> <tr> <td><a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/IncorrectDllVersionW32PTH10DLL">IncorrectDllVersionW32PTH10DLL</a></td> <td><a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/OsWin">OsWin</a></td> <td> 95/98 </td> </tr> <tr> <td><a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/WinDoze95Crash">WinDoze95Crash</a></td> <td><a href="%SCRIPTURLPATH%/view%SCRIPTSUFFIX%/Know/OsWin">OsWin</a></td> <td> 95 </td> </tr> </table> ## <a name="Extract_text_from_a_topic_using_"> Extract text from a topic using regular expressions </a> **Write this:** <code>%SEARCH\{ "\_\_Back to\\:\_\_ TWikiFAQ" scope="text" web="TWiki" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format=" \* $pattern(.\*?FAQ\\:[\\n\\r]\*([^\\n\\r]+).\*) [[$web.$topic]\[Answer...]]" \}%</code> **To get this:** %SEARCH\{ "\_\_Back to\\:\_\_ [[TWikiFAQ]]" scope="text" web="TWiki" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format=" \* $pattern(.\*?FAQ\\:[\\n\\r]\*([^\\n\\r]+).\*) [[Webtopic]]" \}% ## <a name="Creating_Custom_Variables"> Creating Custom Variables </a> * You can add your own preference variables for an entire site, a single web, or a single topic, using the standard syntax. Whatever you include in your variable will be expanded on display, and treated exactly as if it had been written out. So you can place formatted text, page links, image paths. > **Example: Create a custom logo variable** > > <br /> > > * To place a logo anywhere in a web by typing <code>**%MYLOGO%**</code>, simply define the variable on the web's [[WebPreferences]] page. You also have to upload `logo.gif` - this can be done by [[FileAttachment]] to `LogoTopic` (any topic name you choose): > * <code>**Set MYLOGO = %PUBURL%/%MAINWEB%/LogoTopic/logo.gif**</code> -- [[Main/MikeMannix]] - 23 Nov 2001