Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#16 2013-11-12 10:36:07

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

Re: etc_search: when the default search is not enough

wordgasm wrote:

The “live” attribute still produces “true” results even when set to “false”. Why is that?

Hi,

“false” is a string, not a Boolean. You should assign live attribute some “empty” php value: live="0", for example.

Offline

#17 2013-11-15 22:07:13

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

Re: etc_search: when the default search is not enough

Beta 0.9 is released. It is not directly compatible with 0.8.9, so please test it before upgrade. Main news:

  • sensible attributes have migrated to the admin side, mainly for security reasons;
  • pagination should work now, including etc_pagination and other plugins;
  • easier to configure for searching files, images and links.

It is already on duty, though the description still corresponds to the official 0.8.9 version. The plugin help may be a bit outdated too, please complain if so.

Download and feed me back.

Last edited by etc (2013-11-29 14:04:28)

Offline

#18 2013-11-29 14:04:04

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

Re: etc_search: when the default search is not enough

Version 0.9 is released. Both plugin and javascript files must be upgraded. It is not directly compatible with 0.8.9, be careful when upgrading.

More secure and more configurable than the previous version. One can customize search queries, search input form, search results output, animation effects and so on. Accidentally, it can be used as <txp:article_custom /> tag enhanced with powerful where attribute.

The demo is here. But I am still bad at help writing, sorry! :)

Offline

#19 2014-01-15 14:38:42

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: etc_search: when the default search is not enough

Hi Oleg, can you give me an example of how you might implement faceted search using this plug in? I’m just contemplating a potential project and want to know how easy it’s going to be!

Offline

#20 2014-01-15 15:04:13

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

Re: etc_search: when the default search is not enough

Hi Doug,

if you go to plugins homepage, the search in the left sidebar is faceted, accepting term, #keyword or @category. If you search for pag @tips, it will bring you all tips containing “pag”. It’s done with the following etc_search form:

{Title,Body::/^[^@#]/;Title,Keywords::/^#([\w\-]+)$/::{*} LIKE '%$1%';Category1,Category2::/^@([\w\-]+)$/::{*} LIKE '%$1%'}

It contains 3 ;-separated search patterns:

  • Title,Body::/^[^#]/@ means “search for the search string in Title or Body if the string doesn’t start with @ or #”;
  • Title,Keywords::/^#([\w\-]+)$/::{*} LIKE '%$1%': if the search string starts with #, search for the term that follows # in Title or Keywords;
  • and so on

The patterns are of the form

field1,field2,...::regexp_that_triggers_the_pattern::mysql_comparison_operator

Don’t hesitate if you need some help

Offline

#21 2014-01-15 16:13:45

douglgm
Member
From: Bristol
Registered: 2006-08-23
Posts: 182
Website

Re: etc_search: when the default search is not enough

Thanks for the quick reply. I take it you could accomplish something a little more traditional with multiple select fields?

Looks like I’ve got something else to have a play around with!

Offline

#22 2014-01-15 17:32:29

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

Re: etc_search: when the default search is not enough

douglgm wrote #278165:

Thanks for the quick reply. I take it you could accomplish something a little more traditional with multiple select fields?

Combining multiple select fields into one search query is possible, but it would help me a lot to see an example of what you are looking for.

Offline

#23 2014-02-20 16:14:09

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: etc_search: when the default search is not enough

Hi

Is this plugin is working under txp 4.5.5? i tried to install it but failed with error

Parse error: syntax error, unexpected T_FUNCTION in /htdocs/textpattern/lib/txplib_misc.php(812) : eval()'d code on line 392
Les erreurs ci-dessus ont été causées par le plugin :etc_search

Offline

#24 2014-02-23 10:20:57

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

Re: etc_search: when the default search is not enough

Hi Rabah, sorry for the delayed reply (was offline).

Yes, etc_search works with txp 4.5.5 on its homepage (php 5.4). I have also tried a fresh install from the download link that went well. The only reason I can see is that your php version does not support anonymous functions in preg_replace_callback (line 392 in the plugins code). If so, try to declare this function separately:

function etc_search_workaround ($matches) {
	global $etc_search_match;
	@list($res, $sep) = explode('&', $matches[1], 2) + array(null, ',');
	if(!$etc_search_match || !isset($_REQUEST[$res])) {$etc_search_match = false; return '';}
	return urldecode(is_array($res = gps($res)) ? implode($sep, $res) : $res);
}

and replace lines 392—397 with

$params['q'] = trim(!$etc_format ? gps('q') : preg_replace_callback("/\{(.+)\}/Us", 'etc_search_workaround', htmlspecialchars_decode($etc_format)));

Hope that helps.

Offline

#25 2014-02-23 11:16:56

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: etc_search: when the default search is not enough

Hi Oleg thanks for answer!

I tryed to install your plugin on local fresh txp 4.5.5 and it works, then you pointed the php version, it s true that my local is on php 5.3, but the live site is on 5.2.6-1+lenny9!

Good spot about anonymous function, i thinked it s a problem with another plugin (i have more that 20 installed in that website) but it s a php function not supported, maybe add that to the minimum requirement for the plugin (php 5.3)

I mad the modification and the plugin installed and activated without error.

I will try to configure it and test it.

Thanks for your respons Oleg.

Cheers.

Offline

#26 2014-02-23 16:40:35

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

Re: etc_search: when the default search is not enough

Dragondz wrote #279167:

maybe add that to the minimum requirement for the plugin (php 5.3)

Done, thank you for the report. Don’t hesitate if something goes west, the included help is rather succinct.

PS: et mon 1001-ème post va à l’Orient :)

Offline

#27 2014-02-24 09:05:37

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: etc_search: when the default search is not enough

Hi Oleg

I hope i am not bothering you with my questions ;)

I try to replace a content with the target attribute, it works like expected, but i want to restore the initial content if the search is canceled, is it possible? i looked at the js code but it s hard to read a minified javascript!

(look at this link to see what i am doing (the left column) : http://xytest2014.findeur.fr/particulier-entreprise/ )

Offline

#28 2014-02-24 14:16:43

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

Re: etc_search: when the default search is not enough

Dragondz wrote #279184:

Hi Oleg

I hope i am not bothering you with my questions ;)

Hi Rabah, not at all, and better be bothered by questions than by answers anyway. :)

I try to replace a content with the target attribute, it works like expected, but i want to restore the initial content if the search is canceled, is it possible? i looked at the js code but it s hard to read a minified javascript!

You could try to save the html of #listall on page load, and then add if(!html) html = saved_html; before el.html(html); in etcShow function. But I’m not sure it’s a good idea to use the main content area this way, since the live search does not paginate its results. It was rather intended (since the days of cbs_live_search) as a quick preview. You can use <txp:etc_search_results /> for detailed paginated (but not live) output. Maybe they will merge in v.1.0 somehow.

And let me note that you use way too much txp tags for articles count, that could be done much faster (see this article concerning txp tags performance). You’ve been warned about answers! :)

Cheers

Last edited by etc (2014-02-24 14:19:52)

Offline

#29 2014-02-24 17:33:15

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,559
Website GitHub Twitter

Re: etc_search: when the default search is not enough

Hi Oleg

Thanks for the code that really helps me, After some testing i found that putting the previous html code after loosing focus is not very natural when using the search form, then i switshed to another idea: keeping the live search persistant and switch to previous code using external js code by hitting a cancel button, it s better like this i think.

About using a lot of txp code: yes i agree with you about that, but i think right now the code is fast enough regarding the website situation.

Offline

#30 2014-02-24 19:34:26

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

Re: etc_search: when the default search is not enough

Dragondz wrote #279200:

About using a lot of txp code: yes i agree with you about that, but i think right now the code is fast enough regarding the website situation.

Since you use <txp:article pgonly="1" />, I would replace the article_custom / adi_calc construction by the much faster

<txp:variable name="article-count"><txp:php>global $thispage; echo $thispage['total'];</txp:php></txp:variable>

And if you use it for pagination only, etc_pagination could be more pertinent choice.

Offline

Board footer

Powered by FluxBB