Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2013-08-27 00:33:23
- wauterboi
- Member
- Registered: 2013-08-19
- Posts: 11
Re: Help with Advanced Search
I’m back!
http://dotbsp.com/?c=&size=&q=de
This brings up the wrong articles (articles that don’t have “de_” mentioned… ever…)
http://dotbsp.com/?c=counter-strike-global-offensive&size=large&q=
This brings up the same Counter-Strike: Global Offensive map regardless of the size you select. (The map has it’s mapsize variable set to medium.)
Page
<txp:if_search>
<txp:etc_query globals="_GET,_POST" specials="content">
<txp:article mapsize="{?size|%}" />
</txp:etc_query>
</txp:if_search>
Search Input
<div class="search">
<p><h2>Search our archive.</h2>
<form method="get" action="<txp:site_url />">
<select name="c" id="search-option-game" required>
<option value="all" selected="selected">Game</option>
<option value="counter-strike-global-offensive">Counter-Strike: Global Offensive</option>
<option value="counter-strike-source">Counter-Strike: Source</option>
<option value="garrys-mod">Garry's Mod</option>
</select>
<select name="size" id="search-option" >
<option value="" selected="selected">Size</option>
<option value="large">Large</option>
<option value="medium">Medium</option>
<option value="small">Small</option>
</select>
<input id="search-textbox" type="text" name="q" value="" />
<input id="search-button" type="submit" value="<txp:text item='go' />">
</form></p>
This is very strange. I think it’d be better if the “q=” checked the titles and keywords of articles as well.
Last edited by wauterboi (2013-08-27 00:40:11)
Offline
Re: Help with Advanced Search
wauterboi wrote:
http://dotbsp.com/?c=&size=&q=de
This brings up the wrong articles (articles that don’t have “de_” mentioned… ever…)
Are you sure that the link http://dotbsp.com/downloads/de_stantsiya.zip
is not included in the article body?
http://dotbsp.com/?c=counter-strike-global-offensive&size=large&q=
This brings up the same Counter-Strike: Global Offensive map regardless of the size you select. (The map has it’s mapsize variable set to medium.)
That’s “normal”, since empty q
value does not trigger if_search
mode, so size
is ignored. Try to unwrap the etc_query
block from if_search
(and remove other <txp:article />
tags):
<!--txp:if_search-->
<txp:etc_query globals="_GET,_POST" specials="content">
<txp:article mapsize="{?size|%}" />
</txp:etc_query>
<!--/txp:if_search-->
I think it’d be better if the “q=” checked the titles and keywords of articles as well.
You could try wet_haystack or etc_search
plugins to modify the default search fields.
Offline
#15 2013-08-27 19:25:22
- wauterboi
- Member
- Registered: 2013-08-19
- Posts: 11
Re: Help with Advanced Search
Dude, you’re the best. Everything is totally fixed now, from what it seems like! I’ll definitely look into those plugins as well, but this functions exactly how I want it.
One last thing – is there a way to make it check to see if any results come back so I can alert the user if nothing comes back?
Last edited by wauterboi (2013-08-27 19:27:13)
Offline
Re: Help with Advanced Search
wauterboi wrote:
is there a way to make it check to see if any results come back so I can alert the user if nothing comes back?
The usual if_search_results
won’t do it in your case. Check if this convenes (don’t mind an eventual warning):
<txp:etc_query name="article" globals="_GET,_POST"><txp:article mapsize="{?size|%}" /></txp:etc_query>
<txp:if_variable name="article" value="">
Nothing to see here.
<txp:else />
<txp:variable name="article" />
</txp:etc_query>
Edit: removed specials="content"
attribute, for security reasons. Actually, you don’t need a plugin for this little:
<txp:php>
if(!($size = htmlspecialchars(gps('size')))) $size = '%';
parse("<txp:variable name='size'>$size</txp:variable>");
</txp:php>
<txp:variable name="article"><txp:article mapsize='<txp:variable name="size" />' /></txp:variable>
...
Last edited by etc (2013-08-28 08:10:54)
Offline