Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-09-25 21:11:21

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

Display "Searched For" Title Above Results

I am looking for the easiest way to parse out the url so that above my results I can clearly display what was used to return said results. In my url I have string like: …./cars?State=New+Mexico&Model=Honda&Color=Blue&Options=Sun+Roof

I would like it to display:

SEARCHED FOR NEW MEXICO | HONDA | BLUE | SUN ROOF

Sometimes the search string can be longer and sometimes shorter depending on visitors input.

Any guidance would be appreciated.

progre55

Offline

#2 2012-09-25 22:40:13

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Display "Searched For" Title Above Results

adi_gps and some variable/if_variable tags?

Offline

#3 2012-09-26 05:49:34

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: Display "Searched For" Title Above Results

try somethink like this:

<txp:adi_gps />
...
<p>SEARCHED FOR <txp:if_variable name="State" value=""><txp:else/>| <txp:variable name="State"/></txp:if_variable><txp:if_variable name="Model" value=""><txp:else/>| <txp:variable name="Model"/></txp:if_variable><txp:if_variable name="Color" value=""><txp:else/>| <txp:variable name="Color"/></txp:if_variable><txp:if_variable name="Options" value=""><txp:else/>| <txp:variable name="Options"/></txp:if_variable> ...  <txp:if_variable name="OTHER-VARIABLE" value=""><txp:else/>| <txp:variable name="OTHER-VARIABLE"/></txp:if_variable></p>

<txp:rocks/>

Offline

#4 2012-09-26 11:48:10

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

Re: Display "Searched For" Title Above Results

That’s a good testcase for adi_gps beta glue attribute to retrieve GET arrays (“Options” here): <txp:adi_gps glue=" | " />.

Offline

#5 2012-09-26 15:30:33

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

Re: Display "Searched For" Title Above Results

milosevic and etc:

Thanks for the response.

milosevic: your solution worked great for the drop down fields, but not the multi select. Any thoughts …

etc: I have been a little hesitant (scared) to try the adi beta because I am getting ready to roll out site and do not want any last minute gotchas since I know what I have currently works.

progre55

Offline

#6 2012-09-26 16:47:23

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

Re: Display "Searched For" Title Above Results

progre55 wrote:

your solution worked great for the drop down fields, but not the multi select. Any thoughts …

That’s the very problem adi_gps beta should solve; otherwise you still have this ugly etc_query solution:

<txp:variable name="Options"><txp:etc_query globals="_GET" data="{?Options||doarray($|htmlspecialchars).implode (, |$)}" markup="raw" /></txp:variable>

to retrieve a multiselect. But test it carefully with only one “Option” chosen, I am not sure it will be an array in this case.

Edit: sorry, , should be replaced by | in htmlspecialchars.

Last edited by etc (2012-09-26 17:04:04)

Offline

#7 2012-09-26 16:50:42

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

Re: Display "Searched For" Title Above Results

Will do. and I will report back .

Offline

#8 2012-09-26 18:24:39

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Display "Searched For" Title Above Results

Do you need to html encode before displaying to protect from XSS?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#9 2012-09-26 20:08:22

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

Re: Display "Searched For" Title Above Results

Absolutely, and that’s what htmlspecialchars is for in etc_query snippet. But adi_gps does it automatically, so Jorge solution is safe.

Offline

Board footer

Powered by FluxBB