Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-03-06 14:32:07

element
Member
Registered: 2009-11-18
Posts: 99

Search custom field

Hello,

I want to search in a custom field, not that difficult, but the resultpage needs to show all results between a min and max value or up to a value.

The HTML I have is a select-tag.

Show all results up to
<select name="max">
	<option value="" selected="selected">--</option>
	<option value="20">20</option>
	<option value="30">30</option>
	<option value="40">40</option>
	<option value="50">50</option>
</select>
<input type="submit" value="Search"/>

The numbers are hardcoded and not necessarily the value in the customfield.
For example the customfield can have value 41 in it but the resultpage need to show all results up to 40 when the user selected 40.

Last edited by element (2012-03-06 14:33:12)

Offline

#2 2012-03-06 15:31:38

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: Search custom field

Would this post by frickinmuck be of any help?

For example the customfield can have value 41 in it but the resultpage need to show all results up to 40 when the user selected 40.

This is unclear as it seems to obviate the relation between the custom_field value and the user selection. Or do you want to substract 1 from the cf_values? Or adjust all values downward?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2012-03-06 16:18:22

element
Member
Registered: 2009-11-18
Posts: 99

Re: Search custom field

All values downwards, 41 was just an example. It needs to show all results that have a value in the custom field of less than or equal to the search term.

Offline

#4 2012-03-07 01:15:48

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: Search custom field

Not sure of it helps, but wet_haystack features search by custom fields.

Offline

#5 2012-03-07 09:53:22

element
Member
Registered: 2009-11-18
Posts: 99

Re: Search custom field

jstubbs wrote:

Not sure of it helps, but wet_haystack features search by custom fields.

I know about that plugin. What I want is that a website user is able to search in customfield_1 by selecting a number and that the resultpage show all articles with customfield_1 between 0 and the number selected.

Offline

#6 2012-10-10 13:44:41

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: Search custom field

element wrote:

What I want is that a website user is able to search in customfield_1 by selecting a number and that the resultpage show all articles with customfield_1 between 0 and the number selected.

I guess it’s too late now, but etc_search should be able to do it:

<txp:etc_search query="{custom_1::/^\d+$/::{*}<=$0}" />

Last edited by etc (2012-10-11 08:48:47)

Offline

#7 2012-10-10 14:39:35

element
Member
Registered: 2009-11-18
Posts: 99

Re: Search custom field

etc wrote:

I guess it’s too late now, but etc_search should be able to do it:

Looks great, unfortunately queries are not my strong suit.

Last edited by element (2012-10-10 14:42:16)

Offline

#8 2012-10-11 08:49:48

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: Search custom field

That’s quite easy, see the last example on this page.

Offline

Board footer

Powered by FluxBB