Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

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

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,529
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,053
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,529
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,053
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,529
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,053
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

#31 2014-02-25 10:15:48

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

Re: etc_search: when the default search is not enough

Thanks oleg i will try the code.

Here is the result:

Before:

<!-- Runtime:    0,7800 -->
<!-- Query time: 0,324357 -->
<!-- Queries: 149 -->

After:

<!-- Runtime:    0,5686 -->
<!-- Query time: 0,128171 -->
<!-- Queries: 149 -->

Offline

#32 2014-02-25 10:24:23

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

Re: etc_search: when the default search is not enough

Not that way! :) Totally drop your <txp:article_custom /> block, it’s not needed anymore. Just replace it with <txp:variable ...><txp:php>...</txp:php></txp:variable>.

Last edited by etc (2014-02-25 10:26:41)

Offline

#33 2014-02-25 13:23:48

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

Re: etc_search: when the default search is not enough

etc wrote #279217:

Not that way! :) Totally drop your <txp:article_custom /> block, it’s not needed anymore. Just replace it with <txp:variable ...><txp:php>...</txp:php></txp:variable>.

I think it s not possible: the count is depending on article_custom not on txp:article (i put it there only to avoid the anoying message: the page havent a txp:article, but the counting is made using the article_custom itself cause there 4 variables that must be taken (keywords, category, custom_field)

Thanks for your effort to help me polish the website speed

Offline

#34 2014-02-25 17:01:31

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

Re: etc_search: when the default search is not enough

Dragondz wrote #279228:

I think it s not possible: the count is depending on article_custom not on txp:article (i put it there only to avoid the anoying message: the page havent a txp:article, but the counting is made using the article_custom itself cause there 4 variables that must be taken (keywords, category, custom_field)

ah, ok, my bad. But I still think using

<txp:etc_numpages pageby="1" keywords=".." category="..." cf="..." />

from etc_pagination, will be much faster (and cleaner). Actually, you won’t even need this variable, since etc_pagination will do all pagination work. You can also do it in pure <txp:php> with safe_count function.

The reason I insist is that <txp:article_custom /> retrieves the whole data (body, excerpt, …) of >400 articles from db just to count them, unnecessary consuming time and memory. But I leave it with you.

Offline

#35 2014-02-25 17:41:33

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

Re: etc_search: when the default search is not enough

Thanks to point me to that oleg I really appreciate your help.

If i have some time i will investigate further the pagination system but right now it s not possible due to time limit in the project.(and in my life too).

I understund that as a coder we try to make the most efficient code in each work we make and it s a good manner to work, but in the joblife sometimes we must make some compromise and think between the time consuming and result you need, i put in the code what i know right now, it s better than the code i did last year and i hope that my code next year will be better than today.

When i will understund how to use etc_query i think i can say that i have really improved my skills ;)

Really thanks Oleg for all your help again.

Offline

#36 2014-05-13 13:56:20

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

Re: etc_search: when the default search is not enough

I need faceted search in articles with 2 <select>‘s, something like this:

<select name="q">
	<option value="" selected="selected">Choose min value ...</option>
	<option value="2000">< 2000</option>
	<option value="4000">4000</option>
	<option value="6000">6000</option>
	<option value="8000">8000</option>
	<option value="10000">10000</option>
</select>
<select name="q">
	<option value="" selected="selected">Choose max value ...</option>
	<option value="2000">< 2000</option>
	<option value="4000">4000</option>
	<option value="6000">6000</option>
	<option value="8000">8000</option>
	<option value="10000">10000</option>
</select>
<input value="Search" type="submit" />

The search result should show all results tween min and max value selected. The value is stored in custom_1. I tried but couldn’t find a solution.

Last edited by element (2014-05-13 14:19:34)

Offline

Board footer

Powered by FluxBB