Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-04-11 01:50:09

bsaner
Member
Registered: 2011-04-11
Posts: 11

[SOLVED] Search oddness- adding "?q=" to beginning of queries

Hey, I’m new to Textpattern and absolutely love it!

I have noticed some oddness though. When I try to search articles, the search page comes up finding no results because- and here’s the odd part- the search box itself seems to add “?q=” to the search query, and THEN searches for it. so if i search for “example”, it tries to instead search for “?q=example”- which, obviously, finds nothing.

I am not using any plugins as this is a fresh install. it happens with both any style of clean URL/permalink and also with ?q=messy

you can see for yourself at http://moo.jyt.su/

Edit: Super easy fix. See this post for the answer.
I was just using the wrong regex. :)

Last edited by bsaner (2011-04-11 14:16:11)

Offline

#2 2011-04-11 12:28:54

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

What you’re describing is normal Txp behavior. As to why you aren’t getting search results, what changes have you made to the default page template?


Code is topiary

Offline

#3 2011-04-11 12:38:12

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

From what I can see it’s not quite normal behaviour. Search for something in the Search box (e.g. hacker). After submission, look in the search box again. On my installs it just shows the search term; in this case the contents of the search box is prefixed with ?q= :-S

Looks like a default installation so far but, as jsoo says, something in your page template (or, at a push, your server setup) is interfering with the search process. If you post your page template code here, someone might be able to figure it out.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#4 2011-04-11 13:25:50

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

Sure thing; the only changes I made were:
-I added an “excerpts” form
-I have the above form display by default.

Which page/form templates would you like me to post?

Offline

#5 2011-04-11 13:27:41

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

Default page template (let me know if you need any others)…

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=“http://www.w3.org/1999/xhtml” xml:lang=“en” lang=“en”>
<head> <meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />

<title><txp:page_title /></title>

<link rel=“home” href=”<txp:site_url />” />

<txp:feed_link flavor=“atom” format=“link” label=“Atom” /> <txp:feed_link flavor=“rss” format=“link” label=“RSS” />

<txp:css format=“link” />

<txp:rsd />
</head>
<body id=”<txp:if_section name=”“>front<txp:else /><txp:section /></txp:if_section>”>

<!— accessibility —>
<div id=“accessibility”> <ul> <li><a href=”#content”><txp:text item=“go_content” /></a></li> <li><a href=”#sidebar-1”><txp:text item=“go_nav” /></a></li> <li><a href=”#sidebar-2”><txp:text item=“go_search” /></a></li> </ul>
</div>

<div id=“container”>

<!— head —> <div id=“head”> <h1 id=“site-name”><txp:link_to_home><txp:site_name /></txp:link_to_home></h1> <p id=“site-slogan”><txp:site_slogan /></p> </div>

<!— left —> <div id=“sidebar-1”> <txp:section_list default_title=’<txp:text item=“home” />’ include_default=“1” wraptag=“ul” break=“li”> <txp:if_section name=’<txp:section />’>&raquo;</txp:if_section> <txp:section link=“1” title=“1” /> <txp:if_section name=’<txp:section />’> <txp:article_custom section=’<txp:section />’ wraptag=“ul” break=“li”> <txp:if_article_id>&rsaquo;</txp:if_article_id> <txp:permlink><txp:title /></txp:permlink> </txp:article_custom> </txp:if_section> </txp:section_list> <txp:search_input wraptag=“p” />

<p><txp:feed_link label=“RSS” /> / <txp:feed_link flavor=“atom” label=“Atom” /></p> </div>

<!— right —> <div id=“sidebar-2”> <txp:linklist wraptag=“p” />

<p><a href=“http://textpattern.com/”><txp:image id=“2” /></a></p> </div>

<!— center —> <div id=“content”>
<!— list excerpts instead —>
<txp:article form=“default” listform=“excerpt” />

<!— category here —>

<txp:if_individual_article> <div class=“divider”><txp:image id=“1” /></div>

<p><txp:link_to_prev>&#171; <txp:prev_title /></txp:link_to_prev> <txp:link_to_next><txp:next_title /> &#187;</txp:link_to_next></p>
<txp:else /> <p><txp:older>&#171; <txp:text item=“older” /></txp:older> <txp:newer><txp:text item=“newer” /> &#187;</txp:newer></p>
</txp:if_individual_article> </div>

<!— footer —> <div id=“foot”>&nbsp;</div>

</div>

</body>
</html>

I’m not quite sure what’s causing it..

Offline

#6 2011-04-11 13:38:14

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

Further oddness:

-Clicking on “Articles” on the left seems to work just fine (it shunts “articles/” into the search box”, and it seems to behave normally from what I can tell…
-Same as About/“about/” (I haven’t composed any About pages yet).

I’m using Cherokee web server, which may be the cause- instead of using mod_rewrite, it has regexing directly in the daemon’s engine.
The rule I use for URLs to enable clean urls is:
Internal (redirection done server-side)
replace ^/(.*)$ with /index.php?q=$1

Now, interestingly enough after testing it seems when I disable this, search seems to work. But it shouldn’t match that regex, which is what i’m confused about.

So I’m wondering if it’s the internals to TXP; forgive me for the question, but I don’t know much/any PHP. what “happens” when the “submit” button is pressed? where would that ?q= come from based on the request, and is there a way to somehow strip/sanitize that input?

Edit: Let it be known that if the webserver IS the cause, I’ll gladly try to fix it (I certainly don’t expect Textpattern to support me, especially on strange new webserver daemons.); I know of at least one other person using cherokee + textpattern. However, I need to know where/how that search query is being made, what URL formation it sends, to fix it. :)

Last edited by bsaner (2011-04-11 13:49:57)

Offline

#7 2011-04-11 13:50:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,446
Website GitHub

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

bsaner wrote:

-Clicking on “Articles” on the left seems to work just fine (it shunts “articles/” into the search box”

That shouldn’t happen. The search box should only contain stuff you’ve searched for explicitly.

replace ^/(.*)$ with /index.php?q=$1

Ahaaa. Now that might explain it. TXP appends ?q=<your search term> to the URL. If your fake mode_rewrite rule is always adding that to the URL then TXP is going to think everything is a search. Can you use a different letter (or sequence?) in the rule? e.g. something like:

replace ^/(.*)$ with /index.php?bsaner=$1

That should make sure nothing in TXP’s inner workings clashes with your server setup.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Online

#8 2011-04-11 13:52:35

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

Trying now :) thanks for the clue! Give me one moment while i change the regex.

Offline

#9 2011-04-11 13:55:09

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

bsaner wrote:

The rule I use for URLs to enable clean urls is:
Internal (redirection done server-side)
replace ^/(.*)$ with /index.php?q=$1

If that’s the actual rule you are using, then that unfortunately is the cause. That kind of regex would be passing everything after appending slash to q URL parameter, causing all those oddness-es.

Edit. Stef was faster. Like a ninja, posting while I’m reading and typing :-)

Last edited by Gocom (2011-04-11 13:56:30)

Offline

#10 2011-04-11 13:57:12

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

With the regex disabled, and clean urls disabled (just to knock out all possible sources of confusion),

http://moo.jyt.su/?q=hacker

works as expected.

however, i do not seem to have a unique string after index.php?

this is the article link:

http://moo.jyt.su/index.php?id=2

Can this be avoided by perhaps switching to a multi-site configuration, even though I’m only running one s- actually, no. That would only work if search searched across all sites, not just the specific site. hmmm…

Offline

#11 2011-04-11 14:14:42

bsaner
Member
Registered: 2011-04-11
Posts: 11

Re: [SOLVED] Search oddness- adding "?q=" to beginning of queries

hahahahaha..

DUH. I got it! I had a braindead moment.

I just copied over the same RegEx in the .htaccess’s mod_rewrite rules! WHY did I not think of doing that before??

Thank you SO MUCH everyone for your responses! I’m sorry for wasting y’all’s time! But at least now there’s a searchable answer to this question. :)

For the Cherokee users:

Ignore the clean URL method for Wordpress in Cherokee docs.

for Textpattern, the correct redirect is:

Internal
REPLACE ^(.*) WITH index.php

Search, clean urls, etc. should work after that.

Last edited by bsaner (2011-04-11 14:18:21)

Offline

Board footer

Powered by FluxBB