-
☆ A M B ☆
- 24,524 Posts
Ok, here's another question. I have four containers, and I want the user to be able to select a container to act as the "parent" for the search. Can this be done?
-
☆ A M B ☆
- 24,524 Posts
Yes, I have been looking at those examples. But there's no source for the config files used, just the snippet call and the chunk tpls. Likewise the "toolbox" snippets, no code?
[ed. note: sottwell last edited this post 12 years, 10 months ago.]
-
☆ A M B ☆
- 24,524 Posts
Ah, that explains several hours of frustration. I thought I was being particularly stupid by not understanding how those "examples" worked. I was just mistaken in the purpose of the examples, thinking they were to explain how to configure AjaxSearch.
-
☆ A M B ☆
- 24,524 Posts
I got it!
Create a form with the addition of a select drop-down whose values are the IDs of the parent resources:
<form id="[+as.formId+]" action="[+as.formAction+]" method="post">
<fieldset>
<label>
<input id="[+as.inputId+]" type="text" name="search" value="[+as.inputValue+]">
</label>
<label>
<select name="parents" id="selectParents" size="1">
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
</label>
[+as.liveSearch:is=`0`:then=`
<label>
<input id="[+as.submitId+]" type="submit" name="sub" value="[+as.submitText+]" />
</label>
`+]
</fieldset>
</form>
Create a custom config file and put it in the ajaxSearch/configs folder:
$dcfg['parents'] = $_POST['parents'];
And call AjaxSearch:
[!AjaxSearch? &config=`one` &ajaxSearch=`0` &advSearch=`exactphrase` &showInputForm=`1` &tplInput=`asAdvSearchInput`!]
-
☆ A M B ☆
- 24,524 Posts
Here's one way to have a select drop-down that will maintain the user's selection while showing search results on the same page.
<select id="asParents" name="parents">
<option value="0" [+as.selected:is=`0`:or:is=``:then=`selected="selected"`+]>All</option>
<option value="1" [+as.selected:is=`1`:then=`selected="selected"`+]>One</option>
<option value="2" [+as.selected:is=`2`:then=`selected="selected"`+]>Two</option>
<option value="3" [+as.selected:is=`3`:then=`selected="selected"+]>Three</option>
</select>
And in the config file:
$dcfg['parents'] = $_POST['parents'];
$modx->setPlaceholder("as.selected", $_POST['parents']);