summaryrefslogtreecommitdiff
path: root/TWiki/TWikiVariablesExamples.mdwn
blob: 7ffc81658b5da59e4c669f5c7199e472ad3c2035 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
%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