You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tags/search_input.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,7 +86,7 @@ When using a customized form template, Textpattern doesn't automatically wrap th
86
86
87
87
Other tags used: [site_url](/tags/site_url).
88
88
89
-
Note: When displaying search results, Textpattern will use a user defined form named `search_results`, or an internally defined default form if no search result form is nominated/defined.
89
+
Note: When displaying search results, Textpattern will use the form named `search_results`, unless another form is nominated/defined via the `form` attribute or the tag's container.
90
90
{: .alert-block .information}
91
91
92
92
### Example 3: Minimal search input form without label or button (yet still accessible)
Copy file name to clipboardExpand all lines: tags/search_result_count.md
+26-21Lines changed: 26 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,11 @@ tags:
21
21
<txp:search_result_count />
22
22
~~~
23
23
24
-
The **search_result_count** tag is a *single* tag that returns the number of articles returned by an article tag. Use [if_search](/tags/if_search) to count search results or use in regular page after the [article](/tags/article) tag. If you need the results' count *before* the list of results, use the article tag in conjunction with `pgonly="1"` (see example 3).
24
+
The **search_result_count** tag is a *single* tag that returns the number of (live) articles returned by an article tag.
25
25
26
-
Note: The [if_search](/tags/if_search) conditional tag is required to recognize actual search results, without them the number of articles is returned by default.
27
-
{: .alert-block .information}
26
+
* Wrap with [if_search](/tags/if_search) tags to count search results.
27
+
* Use in a regular article list page by wrapping with [if_article_list](/tags/if_article_list) to count articles in that section.
28
+
* Use on the front (default) page to count the number of articles in sections with __On default page__ set to Yes.
28
29
29
30
## Attributes
30
31
@@ -36,44 +37,48 @@ Tag will accept the following attributes (**case-sensitive**) as well as the {%
36
37
37
38
## Examples
38
39
39
-
### Example 1: Display a number of matches
40
+
### Example 1: Display number of search matches or articles in current section
40
41
41
42
~~~html
42
43
<txp:if_search>
43
-
<txp:article />
44
44
<txp:search_result_count />
45
+
<txp:else />
46
+
<txp:if_article_list>
47
+
<txp:search_result_counttext="articles" />
48
+
</txp:if_article_list>
45
49
</txp:if_search>
50
+
51
+
<txp:article />
46
52
~~~
47
53
48
-
If the visitor is searching for articles, it will show the number of articles that matched the search term (e.g. 5) as follows: `5 articles found`.
54
+
If the visitor is searching for articles, it will show the number of articles that matched the search term (e.g. 5) as follows: `5 articles found`. Otherwise, if Textpattern is displaying an article list, it will display the number of articles like this: `42 articles`.
49
55
50
-
Other tags used: [article](/tags/article), [if_search](/tags/if_search).
56
+
Note: The [if_search](/tags/if_search) conditional tag is required to recognize actual search results. Without it, the number of articles is returned by default.
57
+
{: .alert-block .information}
51
58
52
-
### Example 2: Number of matches with custom text
59
+
Other tags used: [article](/tags/article), [if_search](/tags/if_search), [if_article_list](/tags/if_article_list).
60
+
61
+
### Example 2: Number of matches, using custom text
53
62
54
63
~~~html
55
-
<txp:if_search>
64
+
<txp:if_search_results>
56
65
<txp:search_result_counttext="hits" />
57
-
</txp:if_search />
66
+
</txp:if_search_results />
58
67
~~~
59
68
60
69
Displays the number of articles returned (e.g. 5) as follows: `5 hits`.
61
70
62
-
Other tags used: [if_search](/tags/if_search).
71
+
Other tags used: [if_search_results](/tags/if_search_results).
63
72
64
-
### Example 3: Search result count above results
73
+
### Example 3: Regular (live) article count
65
74
66
75
~~~html
67
-
<txp:if_search>
68
-
<txp:articlepgonly="1"limit="20" />
69
-
<txp:search_result_counttext="hits" />
76
+
<txp:if_article_list>
77
+
<txp:search_result_counttext="articles" />
70
78
<txp:articlelimit="20" />
71
-
</txp:if_search />
79
+
</txp:if_article_list />
72
80
~~~
73
81
74
-
Displays the number of articles returned (e.g. 5) as follows: `5 hits` - then displays results as an article listing.
75
-
76
-
Note: The `pgonly` attribute sets the article tag to return pagination statistics without rendering the article list. Care must be taken to remain consistent with article tag attributes to keep statistics accurate.
77
-
{: .alert-block .information}
82
+
Displays the number of articles in the current section, then displays them as an article listing, 20 per page.
78
83
79
-
Other tags used: [article](/tags/article), [if_search](/tags/if_search).
84
+
Other tags used: [article](/tags/article), [if_article_list](/tags/if_article_list).
0 commit comments