Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2012-09-25 22:24:11

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,357
Website

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

adi_gps-0.2 is still available

Offline

#14 2012-09-28 20:36:25

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

etc:

Quick question, I have been unsuccesful in getting anything to come up if the search results come up empty. I removed the ? but am I missing something else. To test, I replaced <txp:article /> with garbage text — but nothing comes up —-

Just not sure what I am missing and to be honest I think everything to this point I tested always had something returned —-

progre55

Offline

#15 2012-09-28 21:11:14

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

You mean, if some search criteria are set, but there is no match? Normally, you should modify article_custom inside etc_query:

<txp:article_custom
  {$?({?Model}|Model='<txp:variable name="Model" />'|)}
  {$?({?Color}|Color='<txp:variable name="Color" />'|)}
  {$?({?Style}|Style='<txp:variable name="Style" />'|)}
  {$?({?Features}|Features='<txp:variable name="Features" />'|)}>
    <txp:title /> and so on
<txp:else />
    no match
</txp:article_custom>

but it does not support <txp:else />, it’s pity. Try to replace it by a second etc_query:

<txp:etc_query globals="variable" data="{?Model}{?Color}{?Style}{?Features}">
  <txp:etc_query markup="raw"
    data='<txp:article_custom {$?({?Model}|Model="{?Model}"|)} {$?({?Color}|Color="{?Color}"|)} {$?({?Style}|Style="{?Style}"|)} {$?({?Features}|Features="{?Features}"|)} />'>
    {{?}}
  <txp:else />
    no match
  </txp:etc_query>
<txp:else />
  <txp:article />
</txp:etc_query>

Edit: sorry, you need double braces in {{?}}.

Last edited by etc (2012-09-28 21:25:31)

Offline

#16 2012-09-28 21:24:02

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

etc.

Weird — first time it returned a blank screen with the word “Nice Try.” — since then it has returned what I placed into it — so I think it is working fine now.

progre55

Last edited by progre55 (2012-09-28 21:25:59)

Offline

#17 2012-09-28 21:29:47

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

As reedited, it works for me. If you have no luck with it, try to find some if_empty plugin.

Offline

#18 2012-09-28 21:30:32

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

Thanks.

Offline

#19 2012-09-29 08:52:14

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

progre55 wrote:

Weird — first time it returned a blank screen with the word “Nice Try.”

Very strange, even with single braces in {?} I have no idea on which door it might have knocked to get this welcome. All it outputs for me in this case are concatenated values of {?Model}{?Color}{?Style}{?Features} variables, i.e. the data of the external etc_query tag.

Offline

#20 2012-10-11 20:37:24

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

etc:

The “Nice Try” I figured out is a TXP default when you have very long url’s. In advanced options, you can adjust the length, which removed that message.

I have tried numrous variations to try to get something to return if the serach resulst are empty. trying your above I thought worked, but what happens is that it tacks the message onto the end of all searches — not just blank one. I was unable to locate an empty plug in — any chance you could throw something together — I would be willing to pay for your time —-

Thanks.

progre55

Offline

#21 2012-10-12 07:43:28

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

progre55 wrote:

what happens is that it tacks the message onto the end of all searches — not just blank one.

That’s weird, I will check it. You can try to replace the internal etc_query by variable/if_variable combination:

<txp:etc_query globals="variable" data="{?Model}{?Color}{?Style}{?Features}">
  <txp:variable name="search_result"
    value='<txp:article_custom {$?({?Model}|Model="{?Model}"|)} {$?({?Color}|Color="{?Color}"|)} {$?({?Style}|Style="{?Style}"|)} {$?({?Features}|Features="{?Features}"|)} />' />
  <txp:if_variable name="search_result" value="">
    no match
  <txp:else />
    <txp:variable name="search_result" />
  </txp:if_variable>
<txp:else />
  <txp:article />
</txp:etc_query>

Just be sure not to introduce extra spaces or linebreaks in value.

Edit: I have checked and found nothing in etc_query that could explain this behavior, at least in the latest version.

Last edited by etc (2012-10-12 13:47:23)

Offline

#22 2012-10-12 19:57:57

etc
Developer
Registered: 2010-11-11
Posts: 4,515
Website GitHub

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

progre55 wrote:

what happens is that it tacks the message onto the end of all searches — not just blank one.

I think I have spotted this behavior once, but am not able to reproduce it anymore. The only scenario I can imagine is a wrongly detected data markup, though I do not see how it’s possible. If so, the variable solution would be affected too, but appending markup=“raw” attribute to the external etc_query should solve the problem. Please let me now how it goes.

Offline

#23 2012-10-12 19:59:19

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

etc.

I will be testing over the wekekend and will get back to you on Monday to let you know. Thanks for the guidance.

progre55

Offline

#24 2013-01-08 18:00:25

progre55
Member
Registered: 2006-05-02
Posts: 668

Re: [howto] Front End Search: Filter Articles With Drop-Down and Multi-Select Menu

I apologize to etc. for not commenting back — I was finally able to get this to work using by replacing the internal etc_query by variable/if_variable combination

Again — thank you etc. for all the assistance.

progre55

Offline

Board footer

Powered by FluxBB