-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathajaxSearch_readme.txt
1687 lines (1223 loc) · 63.6 KB
/
ajaxSearch_readme.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
AjaxSearch Readme version 1.9.2
---------------------------------------------------------------
:: Snippet: AjaxSearch
----------------------------------------------------------------
Short Description:
Ajax-driven & Flexible Search form
Version:
1.9.2 - 05/12/2010
Created by: Coroico - ([email protected])
Jason Coward (opengeek - [email protected])
Kyle Jaebker (kylej - [email protected])
Ryan Thrash (rthrash - [email protected])
----------------------------------------------------------------
:: Credits
----------------------------------------------------------------
Based on Flex Search Form by [email protected]
as modified by KyleJ ([email protected])
and then refactored by Coroico ([email protected])
The document subset selection is based off of the ditto code by Mark Kaplan
The javascript code is based off of the example by Steve Smith of orderlist.com
http://orderedlist.com/articles/howto-animated-live-search/
The search highlighting is based off of the code by Marc (MadeMyDay | http://www.modxcms.de)
The search highlighting plugin is based off of code from sottwell (www.sottwell.com)
The live Search functionality is from Thomas (shadock)
http://www.gizax.it/experiments/AHAH/degradabile/test/liveSearch.html
Many fixes/additions were contributed by mikkelwe/identity/Perrine
Copyright & Licencing:
----------------------
GNU General Public License (GPL) (http://www.gnu.org/copyleft/gpl.html)
Originally based on the FlexSearchForm snippet created by jaredc ([email protected])
----------------------------------------------------------------
:: Changelog: for more details see www.modx.wangba.fr
----------------------------------------------------------------
05-december-10 (1.9.2)
-- Bug fixing
30-august-10 (1.9.2)
-- Bug fixing
18-may-10 (1.9.0)
-- Completely refactored - MVC model implemented
-- Defines categories and display of group of results
-- Several AS call on same page
-- parents (in / not in), documents (in / not in)
-- Custom output
-- Filtering search results by tv name
-- Filter features (allow to set up specific search forms)
-- Bug fixing
20-october-09 (1.8.4)
-- Sites and subsites notions
-- Defines categories and display of group of results
-- Several AS call on same page
-- Bug fixing
14-june-09 (1.8.4)
-- Sites and subsites notions
-- Defines categories and display of group of results
-- Several AS call on same page
-- Bug fixing
08-june-09 (1.8.3)
-- Bug fixing
-- The number of results is available with the [+as.resultNumber+] placeholder
01-mar-09 (1.8.2)
-- liveSearch parameter renamed
-- Initialisation of configuration parameters is modified
-- mbstring parameter added
-- Limit the amount of keywords that will be queried by a search
-- Capturing failed search criteria and search logs
-- Compatibility with mootools 1.2.1 library
-- Compatibility with jquery library
-- Always display paging parameter added
-- Bug fixing
02-oct-08 (1.8.1)
-- subSearch added.
-- mysql query redesigned.
-- whereSearch parameter improved. Fields definition added
-- withTvs parameter added. specify the search in Tvs
-- # metacharacter for filter
-- improvement of the searchword list parameter
-- debug - file and firebug console
-- Bug fixing
21 -July-08 (1.8.0)
-- define where to do the search (&whereSearch parameter)
-- define which fields to use for the extracts (&extract parameter)
-- use AjaxSearch with non MOdx tables
-- order the results with the &order parameter
-- define the ranking value and sort the results with it
-- filter the unwanted documents of the search
-- define the extract eliipsis
-- define the extract separator
-- Extended place holder templating and template parameters
-- Improvement of the extract algorithm
-- Define the number of extracts displayed in the search results
-- Use of &advSearch parameter available from the front-end by the end user
-- Choose your search term from a predefined search word list
-- stripInput user function
-- stripOutput user function
-- Configuration file and $__ global parameters
-- snippet code completely refactored and objectified
-- Bugfixes regarding Quoted searchstring
06-Mar-08 (1.7.1)
-- Advanced search (partial & relevance)
-- Search in hidden documents from menu
-- List of Ids limited to parent-documents ids in javascript
-- Code cleaning
06-Jan-08 (1.7)
-- Added custom config file
-- Added list of parent-documents where to search
-- Added opacity parameter (between 0 (transparent) and 1 (opaque)
-- Added bugfixes regarding opacity with IE
-- Using of DBAPI function instead of deprecated function
-- Charset troubles corrected
22-Jan-07 (1.6)
-- Added templating support (includes/templates.inc.php)
-- Added language support
-- Switched from prototype/scriptaculous to Mootools
03-Jan-07 -- Added many bugfixes/additions from AjaxSearch forum
18-Sep-06 -- Added code to only show results for allowed pages
05-May-06 -- Added liveSearch functionality and new parameter
21-Apr-06 -- Added code to make it compatible with tagcloud snippet
20-Apr-06 -- Added code from eastbind & japanese community for other language searching
04-Apr-06 -- Added search term highlighting
01-Apr-06 -- initial commit into SVN
30-Mar-06 -- initial work based on FSF_ajax from KyleJ
----------------------------------------------------------------
:: Description
----------------------------------------------------------------
Ajax and non-Ajax search that supports results highlighting.
This snippet adds AJAX functionality on top of the robust content searching.
What AjaxSearch do:
- search in fields of the content an TV MODx tables
- several customizable input forms available
- search in a subset of documents
- highlighting of searchword in the results returned
- allow a filtering of search results
- displaying of search results customizable thru templates
- group the search results by categories
- filter features (allow to set up specific search forms)
It could works in two modes:
ajax mode :
- search results displayed in current page through AJAX request
- multiple search options including live search
- available link to view all results in a new page when only a subset is returned
- customize the number of results returned
- offer two types for paginating the results
- uses the MooTools or JQuery js library for AJAX and visual effects
non-ajax mode :
- search results displayed in a new page or below on the same page
- offer two types for paginating the results
- works without JS enabled
What AjaxSearch don't :
- search in dynamic content. AjaxSearch could retreive only data stored in
database. It can't find something stored in a chunk or generated by a snippet.
MORE : See the ajaxSearch.readme.txt file for more informations.
----------------------------------------------------------------
:: General Parameters (all are optional parameters)
----------------------------------------------------------------
Keep in mind that all parameters are optional.
If not used, the default value of each parameter will be applied
The simplest snippet call is [!Ajaxsearch!] without any parameters.
---- &config [config_name | "default"] (optional)
Load a custom configuration
config_name - Other config installed in the configs folder or in any folder within the MODx base path via @FILE:
Configuration files are named in the form: <config_name>.config.php
To limit the number of javascript variables, the default parameters are stored in the default.config.inc.php file.
This file is read by the ajaxSearch class and by the ajaxSearchPopup class.
The only parameters transmitted by JavaScript to the ajaxSearchPopup class are:
- the subSearch and the advSearch parameters
- the parameters used in the snippet call
Keep care that all the default values defined in the default.config.php should be defined in your own config file
Parameters in the config file should be defined as php variables. e.g:
$ajaxMax = 4;
To avoid to overwrite the parameters used in the snippet call use $__ instead of $ e.g:
$__ajaxMax = 4;
For instance, in a AjaxSearch call if we have [!AjaxSearch? &landingPage=`25`] and
in the config file $__landingPage = `12`; that means that by default the page #12
will be used as a landing page, except in the document where &landingPage=`25`
is set in the snippet call.
---- &debug = [ 0 | 1 | 2 | 3 ] (optional) - Output debugging information
0 : debug not activated (Default)
1, 2, 3 : File mode
debug activated. Trace is by default logged into a file named ajaxSearch_log.txt
in the ajaxSearch/debug/ directory.
1 : Parameters, search context and sql query logged.
2 : Parameters, search context, sql query AND templates logged
3 : Parameters, search context, sql query, templates AND Results logged
To avoid an increasing of the file, only one transaction is logged. Overwritted
by the log of the following one.
IMPORTANT: the ajaxSearch/debug directory should exist and be writable
---- &language [ language_name | manager_language ] (optional)
with manager_language = $modx->config['manager_language'] by default
See in the lang folder the languages available
---- &timeLimit = [ int | 60 ] (optional)
&timeLimit = [ int | 60 ]
Max execution time in seconds for the AjaxSearch script
0 - If set to zero, no time limit is imposed
Default: 60 - 1 minute.
---- &asId [ string | ''] - Unique id for AjaxSearch instance (optional)
Any combination of characters a-z, underscores, and numbers 0-9
This is case sensitive. Default = empty string
This parameter allow distinguish several Ajaxsearch instances on the same page
The id is used to link the snippet calls between them.
Choose a short name. eg: "as2"
---- &ajaxSearch [1 | 0] (optional)
Use the ajaxSearch mode. Default is 1 (true)
The AjaxSearch mode use an Ajax call to get the results without full page reloading
---- &advSearch [ 'exactphrase' | 'allwords' | 'nowords' | 'oneword' ] (optional)
Advanced search
- exactphrase : provides the documents which contain the exact phrase
- allwords : provides the documents which contain all the words
- nowords : provides the documents which do not contain the words
- oneword : provides the document which contain at least one word [default]
---- &subSearch : [comma separated list of sites] (optional)
subSearch allow to define sub-domains or sites where to do the search
for each site, a search function should be defined in the configuration file
e.g: &subSearch=`products,employee`
---- &category [ tv_name | '']
Any combination of characters a-z, underscores, and numbers 0-9
This is case sensitive. Default = empty string
Name of a TV. The category of a MODx document is provided by this TV content
e.g: &category=`category`
And the "category" tv value of a document could contain for instance Music, Arts, ...
Then the categConfig function should be defined like that:
/*
* categConfig : To define the display of categories (output)
* Add a category as a switch item. 'uncategorized' item describe the results outside of any category
* Add a switch for a new site. The default site is named 'defsite'.
* Allowed config parameters : grpLabel, tplResult, tplAjaxResult, display, extract, rank ...
*/
if(!function_exists('categConfig')) {
function categConfig($site='defsite',$category){
$config = array();
$site = strtolower($site);
$category = strtolower($category);
switch($site) {
case 'defsite':
switch($category){
case 'arts':
$config['grpLabel'] = 'Arts';
$config['tplAjaxResult'] = 'imgResult'; // allow the display of an image
break;
case 'music':
$config['grpLabel'] = 'Music';
$config['tplAjaxResult'] = 'imgAjaxResult'; // allow the display of an image
break;
case 'geography':
$config['grpLabel'] = 'Geography';
$config['tplAjaxResult'] = 'imgAjaxResult';
break;
case '':
$config['grpLabel'] = 'Site wide';
break;
}
}
return $config;
}
}
---- &display [ 'mixed' | 'unmixed' ] (optional)
When results comes from differents sites or categories, you choose to display the results
mixed or unmixed. Unmixed mode display the results grouped by site or category.
Mixed mode mixe all the results from all the site. Results are ordered by each field
provided by the first field choosen for the order parameter
Default: unmixed
---- Label for a group of results
in the configuration file a label could be defined to be be linked with the group of results.
This isn't a snippet parameter. Only a variable of configuration file.
This variable shouldn't contain a comma (",")
$config['grpLabel'] = 'Arts (Painting)';
---- &whereSearch : [comma separated list of key | content,tv] (optional)
define in which tables the search occurs
by default in documents and TVs
other predefined key: jot, maxigallery
by default all the text fields are searchable but you could specify the fields like this:
whereSearch=`content:pagetitle,introtext,content|tv:tv_value|maxigallery:gal_title`
You could also add your own tables where to do a search by defining your own keys.
---- &withTvs : [ [ + | - ] [ : tvlist] ] (optional)
The parameter withTvs define which Tv will be added as field result for displaying
and in which tv the search will occur. Only text type TV are enabled
e.g:
&withTvs=`tv1,tv2,tv3` - tv1, tv2, Tv3 are added
&withTvs=`+:tv1,tv2,tv3` - tv1, tv2, Tv3 are added
&withTvs=`+` - all tvs of the site are added
&withTvs=`-` - all tvs of the site are added
&withTvs=`-:tv1,tv2,tv3` - all tvs of the site except tv1, tv2, Tv3 are added
&withTvs=`` - no tv added
If &whereSearch contains 'tv' then a tv_value field which contain the concatened
values of all tv of the document is added
So the tv added could be used for filtering with the filter parameter (see &filter)
Like the default site content parameters (pagetitle, longtitle, ...) the
Tvs enabled as results are available with the following placeholders:
[+as.tvname+], [+as.tvnameShow+], [+as.tvnameClass+]
Where tvname is the MODx name of a TV
[+as.tvname+] is the HTML output of your TV
[+as.tvnameShow+] = 1 if the TV is not NULL
[+as.tvnameClass+] :
- ajaxSearch_resultTvname for the non ajax results (&tplResult)
- AS_ajax_resultTvname for the ajax window (&tplAjaxResult)
---- &tvPhx : [ [ + | - ] [ : tvlist] ] (optional)
append the content of some Tvs to your search results with the "tvPhx" parameter
by default ''
The parameter tvPhx define which additional tv will be added as placeholder.
e.g:
&tvPhx=`tv1,tv2,tv3` - tv1, tv2, Tv3 are added as placeholders
&tvPhx=`+:tv1,tv2,tv3` - tv1, tv2, Tv3 are added as placeholders
&tvPhx=`+` - all tvs of the site are added as placeholders
&tvPhx=`-` - all tvs of the site are added as placeholders
&tvPhx=`-:tv1,tv2,tv3` - all tvs of the site except tv1, tv2, Tv3 are added as placeholders
&tvPhx=`` - no tv defined as placeholders.
The following placeholders are anabled with the tv:
[+as.tvname+], [+as.tvnameShow+], [+as.tvnameClass+]
Where tvname is the MODx name of a TV
[+as.tvname+] is the HTML output of your TV
[+as.tvnameShow+] = 1 if the TV is not NULL
[+as.tvnameClass+] :
- ajaxSearch_resultTvname for the non ajax results (&tplResult)
- AS_ajax_resultTvname for the ajax window (&tplAjaxResult)
The tv value could be used with the filter parameter (see &filter)
As withTvs includes the TV as a new field in the select clause of the mysql query,
tvPhx append the content of the selected tv after the search and before filer.
---- &order (optional)
Define in which order are sorted the displayed search results
`comma separated list of fields`
by default: 'publishedon,pagetitle' (sorted by published date and then pagetitle)
The fields should come from the tables used and defined from the whereSearch parameter
You could add DESC to sort by decreasing order. By default increasing order (ASC) is used.
e.g : &order=`longtitle DESC,introtext`
---- &rank (optional)
define the ranking of search results
&rank=`comma separarted list of fields with optionaly user defined weight`
by default: pagetitle:100,extract
The rank is a calculated value used to sort the results. This value is function of
number of search term found and optionaly of a specified user weight.
e.g: &rank=`pagetitle:100,extract`
rank['pagetitle'] = nb_search_terms_found * 100
rank['extract'] = nb_search_terms_found * 1
Results are sorted with the rank values.
For instance, a document with a search term found in the pagetitle, and 6 terms found
in the extract will have a rank of 106.
e.g: &rank=`pagetitle,extract`
rank['pagetitle'] = nb_search_terms_found * 1
rank['extract'] = nb_search_terms_found * 1
---- &maxWords [ 1 < int < 10 ] (optional)
Maximum number of words for searching - Default: 5
---- &minChars [ 2 < int < 100 ] (optional)
Minimum number of characters to require for a word to be valid for searching.
Length of each word with $advSearch = 'allwords', 'oneword' or 'nowords'
Length of the search string with possible spaces with $advSearch = 'exactphrase'
---- &showInputForm [1 | 0] (optional)
Show the search input form. Default is 1 (true)
---- &showResults [1 | 0] (optional)
Show the results with the snippet. (For non-ajax search)
---- &extract [int : Comma separated list of displayable fields | '1:content,description,introtext,tv_value] (optional)
Define the maximum number of extracts that will be displayed per
document and define which fields will be used to set up extracts
An extract is a bit of text where search term have been found (and may be highlighted).
&extract is different of &whereSearch.
&extract define which fields will be used to set up the text where to extract the search term.
&whereSearch define which tables use for the search (and then provides a list of displayable
fields where to search and possibly used by &extract)
&extract : `int : Comma separated list of searchable fields`
int:
0 - no extract
n - n extracts allowed per document.
Comma separated list of displayable fields:
The field names used for the extract come from the "displayed" fields of
tables defined by the &whereSearch parameter (main and joined tables)
Searchable fields are string type fields that can could contain the search terms.
For "content", the searcheable fields available are:
pagetitle, longtitle, description, alias, introtext, menutitle, content
For "tv", the fields available are :
tv_value which is a concatenation of all the tv "values" field
For "jot", the fields available are :
jot_content which a concatenation of all the "content" fields of jot table
For "maxigallery", the fields available are :
gal_title, gal_descr which are a concatenation of title & descr fields of maxigallery table
e.g: &extract=`5:description,introtext,content,tv_value`
allows a maximum of 5 extracts per document found by search.
Extracts display content from description,introtext,content of document AND
tv_value from all the TV linked with the document
e.g: &whereSearch=`content,maxigallery` &extract=`10:galtitle,galdescr`
allows a maximum of 10 extracts per document found by search.
Extract are built by parsing ONLY the fields title and descr of maxigallery
e.g: &whereSearch=`content,tv,jot` &extract=`tv_value,jot_content`
allows a maximum of 1 extract per document found by search (by default)
Extracts display content from tv_value (TV values) and jot_content (comment)
---- &extractEllips : define your ellipsis in extract (optional)
string used as ellipsis to start/end an extract
by default : " ... "
---- &extractSeparator : Define how separate extracts (optional)
html tag like <br /> or <hr /> or any other html tag
Default : "<br />"
---- &extractLength [50 < int < 800] (optional)
Length of extract around the search words found - between 50 and 800 characters
---- &formatDate [ string ] (optional)
The format of outputted dates. See http://www.php.net/manual/en/function.date.php
by default : "d/m/y : H:i:s" e.g: 21/01/08 : 23:09:22
---- &hideMenu [ 0 | 1 | 2 ] (optional)
Search in hidden documents from menu
- 0 : search only in documents visible from menu
- 1 : search only in documents hidden from menu
- 2 : search in hidden or visible documents from menu [default]
---- &hideLink [0 | 1] : Search in content of type reference (optional)
- 0 : search in content of document AND reference type
- 1 : search only in content of document type (default)
---- &parents [ [ in | not in ] : comma separated list of Ids | '' ] (optional)
A list of parent-documents whose descendants you want searched to &depth depth when searching.
All parent-documents by default
e.g:
&parents=`in:24,25` - do the search in the children documents of documents 24 and 25
&parents=`not in:24,10` - do the search in all documents except in the children documents of documents 24 and 10 documents
&parents=`24,25` means &parents=`in:24,25` (compatible with the 1.8.4 release)
&depth [ 0 < int ] Number of levels deep to retrieve documents
---- &depth [int] (optional)
Number of levels deep to go.
Any number greater than or equal to 1. 10 levels by default
---- &documents [ [ in | not in ] : comma separated list of Ids | '' ] (optional)
A list of documents where to search
e.g:
&documents=`in:28,29,30,31` - do the search in the documents 28,29,30,31
&documents=`not in:28,29,30,31` - do the search in all documents except in documents 28,29,30,31
&documents=`28,29,30,31` means &documents=`in:28,29,30,31` (compatible with the 1.8.4 release)
---- &filter : exclude unwanted documents (optional)
&filter runs as the &filter Ditto 2.1 parameter.
(see http://ditto.modxcms.com/tutorials/basic_filtering.html)
&filter=`field,criterion,mode`
Where:
"field" is the name of any field from main table (site content) or joined table (jot, maxigallery) or a tv name
"criterion" is a value of the same data type (number, string, date, etc.) as the field.
"mode" is a number from 1 to 8 that specifies what kind of comparison to make
between the value of the field and the specified criterion.
"," (comma) is the "Local Filter Delimiter", i.e. the character that tells
where the division is between the three parts of the clause.
There must be no spaces in the "criteria" term unless you want them used in the comparison.
The filter clause: id,50,2 means "exclude any document whose id field equals 50."
The filter clause: articleTags,volcano,7 display only documents related to volcanoes (tv name = articleTags)
A filter may include multiple clauses, separated by the global delimiter, in the form: clause|clause|clause|etc.
Where:
"clause" is any filter clause as defined above.
"|" (the pipe symbol) is the Global Filter Delimite, the character that
tells Ditto where the division is between clauses.
"etc." means there is no fixed limit to the number of clauses you may include.
Multiple clauses have an "OR" relationship. I.e. a document will be excluded
if it meets the criterion of any one clause (clause-1 OR clause-2 OR clause-3, etc.).
The filter id,50,2|id,52,2 means "exclude any document whose id field equals 50 or 52."
Comparison Modes
Exclude a document if its value in the specified field
1 is not equal to the criterion (!=)
2 is equal to the criterion (==)
3 is less than the criterion (<)
4 is greater than the criterion (>)
5 is less than or equal to the criterion (<=)
6 is greater than or equal to the criterion (>=)
7 does not contain the text of the criterion
8 does contain the text of the criterion
9 case insenstive version of #7 - does contain the text of the criterion
10 case insenstive version of #8 - does contain the text of the criterion
IMPORTANT : here the tv should be allowed as result with the withTvs or tvPhx parameters
---- &stripInput user function (optional)
to transform on fly the search input text
by default: defaultStripInput
StripInput user function should be define in the config file as follow :
// StripInput user function.
// string functionName(string $searchstring)
// functionName : name of stripInput function passed as &stripInput parameter
// $searchstring : string php variable name as searchString input value
// return the filtered searchString value
/*
function myStripInput($searchString){
Any Php code which filter the input search string
The following internal functions could be called:
$searchString = stripHtml($searchString) : strip all the html tags
$searchString = stripHtmlExceptImage($searchString) : strip all the html tags execpt image tag.
$searchString = stripTags($searchString) : strip all the MODx tags
$searchString = stripSnip($searchString) : strip all the snippet names
You could also developp you own filter based on regular expressions.
See http://fr.php.net/manual/en/intro.pcre.php
return $searchString;
}
By default : defaultStripInput function will be used if &stripInput parameter
is not set or if the function is not defined :
function defaultStripInput($searchString){
if ($searchString != ''){
// Remove escape characters
$searchString = stripslashes($searchString);
// Remove modx sensitive tags
$searchString = stripTags($searchString);
// Strip HTML tags
$searchString = stripHtml($searchString);
}
return $searchString;
}
---- &stripOutput user function (optional)
to transform on fly the result output
by default: defaultStripOutput
StripOutput user function should be define in the config file as follow :
// string functionName(string $text)
// functionName : name of stripOutput function passed as &stripOutput parameter
// $text : string php variable name as results
// return the filtered results
/*
function myStripOutput($text){
Any Php code which filter the results
The following internal functions could be called:
$text = stripTags($text); // strip all the MODx tags
$text = stripJscript($text); // strip jscript
$text = stripLineBreaking($text); // replace line breaking tags with whitespace
$text = stripHtml($text); // strip all the html tags
You could also developp you own filter based on regular expressions.
See http://fr.php.net/manual/en/intro.pcre.php
return $text;
}
*/
By default : defaultStripOutput function will be used if &stripOutput parameter
is not set or if the function is not defined :
function defaultStripOutput($text){
// replace line breaking tags with whitespace
$text = stripLineBreaking($text);
// strip modx sensitive tags
$text = stripTags($text);
// strip Jscript
$text = stripJscripts($text);
// strip html tags. Tags should be correctly ended
$text = stripHTML($text);
return $text;
}
---- &showIntro [ 0 | 1 ] - introduction message under the input form (optional)
To show or hide the introduction message displayed with the input form
Default: 1 (show)
---- &clearDefault (optional)
clearing default text: [1 | 0]
Set this to 1 if you would like to include the clear default js function
add the class "cleardefault" to your input text form and set this parameter
When the user clicks on the box, the default text is wiped away so that they
can begin typing. If they click away from the box, without typing anything in,
we will add the default text back so that they don’t forget what was meant to
be typed.
See http://www.yourhtmlsource.com/forms/clearingdefaulttext.html
e.g : &clearingDefault=`0`
To work the input text should contains the class="cleardefault"
e.g (from templates/layoutTpl):
<input class="cleardefault" id="ajaxSearch_input" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
Could be used with all the input text forms of your site
The location of the js library is set with &jsClearDefault and the default
file is : js/clearDefault.js
---- &jsClearDefault (optional)
Location of the clearDefault javascript library
---- &breadcrumbs (optional)
0 : disallow the breadcrumbs link
Name of the breadcrumbs function : allow the breadcrumbs link
The function name could be followed by some parameter initialization
e.g: &breadcrumbs=`Breadcrumbs,showHomeCrumb:0,showCrumbsAtHome:1`
The breadcrumbs function could be custom function or a snippet
The function nor the snippet should in any case exist
Breadcrumbs user function could be define in the config file as follow :
// Breadcrumbs user function.
// string functionName(array $main, array $row, array $params)
// functionName : name of breadcrumbs function passed with &breadcrumbs parameter
// $main : array as main table definition
// $row : array as search result row
// $params : array as breadcrumbs parameters passed with &breadcrumbs parameter
// return the breadcrumbs link as a string
function myBreadcrumbs($main, $row, $params){
// use $main, $row and $params to set up your own custom breadcrumbs
return $breadcrumbs;
}
---- &addJscript [1 | 0] (optional)
Set this to 0 if you would like to include the mootool/jquery librairy in the header of your pages manually.
By default set to 1. The library is added automatically
---- &jscript ['jquery'|'mootools2'|'mootools'](optional)
Set this to jquery if you would like use the jquery library
set mootools2 to use the version 1.2 of mootools (limited to JS functions used by AS)
Default: 'mootools' - use the version 1.11 of mootools provided with MODx
---- &jsMooTools
Location of the mootools javascript library
by default: 'manager/media/script/mootools/mootools.js'
---- &jsMooTools2
Location of an alternative mootools javascript library
Default: AS_SPATH . 'js/mootools1.2/mootools.js' - contains only the required functions for AS
to use an another library, use this parameter and change the ajaxSearch/js/ajaxSearch1/ajaxSearch-mootools2.js file
---- &jquery
Location of the jquery javascript library
by default: AS_SPATH . 'js/jquery.js'
---- &mbstring (optional)
Set to 0 if you can't load the php_mbstring extension
by default: 1
---- &tplInput - chunk to style the input form (optional)
by default: @FILE:".AS_SPATH.'templates/input.tpl.html
The folder inputs provide several input chunks.
Input 1 : a simple search (oneword) with a simple input field.
Input 2 : an advanced search. An input field with the selection of the advanced Search parameter
Input 3 : a simple search (oneword) with a multiple input list
---- &pagingType [ 0 | 1 | 2 | 3 ] : type of pagination - (optional)
Default: 1
0: Results Pages 1 | 2 | 3
1: Previous - X-Y /Z - Next
2: X-Y /Z - Show more 10 results
Type 0 for non-ajax mode only
Type 1 for non-ajax and ajax mode
Type 2 for ajax mode (Jquery only)
&tplPaging0 - Chunk to style the paging links - type 0
&tplPaging1 - Chunk to style the paging links - type 1
&tplPaging2 - Chunk to style the paging links - type 2
IMPORTANT:
arrow button images are provided with the images folder.
use asprev.png, asnext.png or your own images to define your previous and next buttons.
e.g:
.paging1Prev{ width:16px; margin:0 3px 0 0;display:block; float:left; text-indent:-3000px; background:url(images/asprev.png) 0 center no-repeat; }
.paging1Next{ width:16px;display:inline-block;text-indent:-3000px; background:url(images/asnext.png) 0 center no-repeat; }
.paging2More{ margin:10px 10px; padding:8px;background:url(images/asnext.png) 0 center no-repeat;}
---- &output [ 0 | 1 ] : Custom output - (optional)
0 - by default the results are listed below the input form
1 - custom layout:
To place the different AjaxSearch elements where you want, use the following placeholders
[+as.inputForm+] : the input form with the intro message
[+as.results+] : the search results
The parameter &tplLayout is now deprecated
The parameter &tplInput is now used to style the ajaxSearch input form
---- &asLog - ajaxSearch log [ level [: comment [: purge]]]
level:
0 : disallow the ajaxSearch log (default)
1 : failed search requests are logged
2 : all ajaxSearch requests are logged
comment:
0 : user comment not allowed (default)
1 : user comment allowed
purge: number of logs allowed before to do an automatic purge of the table
0 : no purge allowed (= illimited number of logs)
default: 200
&asLog=`x` is equivalent to &asLog=`x:0:200`
&asLog=`x:y` is equivalent to &asLog=`x:y:200`
&asLog=`1:1:500` means that 500 failed search requests possibly commented
by the end user could be stored in the ajaxSearch_log table
&asLog=`1:1:500` means that 500 failed search requests possibly commented
by the end user could be stored in the ajaxSearch_log table
---- &tplComment
chunk to style comment form
by default: @FILE:".AS_SPATH.'templates/comment.tpl.html'
The comment form is protected from spamming by the use of a hidden input field.
(idea suggested from SPForm by Bob Ray ) This field should be hidden by the
CSS styling. If it's filled in (presumably by spammer autobots) nothing is sent.
The "hidden" content is not really hidden, just not visible, so no worries
about being penalized by Google. Visually challenged users of
text-only browsers or audio browsers MAY see the input field and fill it
(although the text warns them not to).
You need to paste the following code into your CSS file. Otherwise the field will not be hidden.
.ajaxSearch_hiddenField {
position:absolute;
text-decoration:underline;
background-color:#CC0000;
left:0px;
top:-500px;
width:1px;
height:1px;
overflow:hidden;
}
Keep spammers from pasting too many links into the comment and sending it(counts "http" instances);
A maximum of 2 links per comment is allowed otherwise the comment is rejected.
You could adjust this value in the file classes/ajaxSearchLog.class.inc by changing the CMT_MAX_LINKS definition.
The maximum length of the comment is of 100 characters. Otherwise the comment is rejected.
Helps short-circuit injection attacks. You could this value in the file classes/ajaxSearchLog.class.inc by
changing the CMT_MAX_LENGTH definition.
The user searches are stored in the database table $modx_table_prefix."ajaxsearch_log"
These data are not for the end user only for the site administrator.
Informations stored per each search are the following:
- id : internal id of the search request looged
- searchstring : the search terms used for the search
- nb_results : number of results found
- results : document ids found
- comment : comment leave by the user regarding the search results
- as_call : ajaxSearch snippet call used
- as_select : select statement used (could be reused thru phpmyadmin)
vdate : date and hour of the request
- ip : user IP
The table could be drop without any impacts on the AjaxSearch behaviour. Simply,
if the asLog parameter is set and the table inexisting, the table is rebuilt.
A 'Did you find what you are looking for?' form is available for the user when the option comment is set.
In this case the user could leave a comment about the search results.
&tplComment parameter define which form template used.
A module will be provided later to manage these search datas
We could imagine the following features:
- drop the table
- delete (successfull, unsuccessfull, all) searches executed before a specific date
- delete (successfull, unsuccessfull, all) searches executed before N days
- give me as meta tag keywords, the N most used (successfull, unsuccessfull) search terms
- replay a specific search with a new debug level
- delete uncommented (successfull, unsuccessfull, all) searches
- filter view with commented (successfull, unsuccessfull, all) searches
----------------------------------------------------------------
:: Ajax Parameters - Used only with the ajaxSearch mode
----------------------------------------------------------------
---- &ajaxMax [int] (optional)
The number of results you would like returned from the ajax search.
---- &showMoreResults [1 | 0] (optional)
If you want a link to show all of the results from the ajax search.
---- &moreResultsPage [int] (optional)
Page you want the more results link to point to. This page should contain
another call to this snippet for displaying results.
---- &liveSearch [1 | 0] (optional)
There are two forms of the ajaxSearch.
0 - The form button is displayed and searching does not start until the button is pressed by the user.
1 - There is no form button, the search is started automatically as the user types (liveSearch)
---- &opacity [float value between 0. and 1.] (optional)
Opacity of the ajaxSearch_output div where are returned the ajax results. Default is 1.
Float value between 0. (transparent) and 1. (opaque)
---- &addJscript [1 | 0] (optional)
If you want the mootools library added to the header of your pages automatically set this to 1.
Set to 0 if you do not want them inculded automatically. Default is 1.
---- &tplAjaxGrpResults
chunk to style the ajax output group of results outer
by default: @FILE:".AS_SPATH.'templates/ajaxGrpResults.tpl.html'
---- &tplAjaxResults
chunk to style the ajax output results outer
by default: @FILE:".AS_SPATH.'templates/ajaxResults.tpl.html'
---- &tplAjaxResult
chunk to style each output result