We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Search setup using simple_form on submit just goes to my site’s home page

Development and Programming

TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Subject pretty much says it all.

I have a simple search form setup and when you submit your search, it just directs you to the home page instead of the search/results template.

{exp:search:simple_form result_page="search/results" results="20" status="open"}
<div class="search">
<input type="text" class="searchBox" name="keywords" id="keywords" value="" maxlength="100" />
</div>
{/exp:search:simple_form}

Can be seen in action here: http://www.findyourgeek.com/reviews/

Moved to Development and Programming by Moderator

       
Dan Decker's avatar
Dan Decker
7,338 posts
14 years ago
Dan Decker's avatar Dan Decker

Hi Tom,

Sorry this has been an issue for you.

From the code you posted, you have not specified a channel to search in. The example in the User Guide can point you in the right direction. If you need to search across multiple channels, that can accomplished by looking here.

I hope this helps clear that up for you! Let us know if you need further assistance.

Best,

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Dan,

Even when I specify a channel in the search tag it just lands on my home page.

It’s submitting the form to the home page as well.

Thanks, Tom

       
Brandon Jones's avatar
Brandon Jones
5,500 posts
14 years ago
Brandon Jones's avatar Brandon Jones

Tom,

What version of EE are you using?

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT
You are running the latest version of ExpressionEngine: Version 2.1.3 Build 20110411
       
Kyle Cotter's avatar
Kyle Cotter
730 posts
14 years ago
Kyle Cotter's avatar Kyle Cotter

Hey Tom,

By any chance are you forcing the addition or removal of ‘www’ by means of an .htaccess file? If you’re not sure, can you paste your .htaccess file here for us.

If you are doing that, can you try removing that rule, and then seeing if the form will submit?

If it’s able to submit, sans the ‘www’ override, then that means the form domains are mismatching, so the form submission fails. So make sure you stay consistent throughout the site if that’s the problem.

Hope this helps.

Thanks!

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Kyle,

Here is my .htaccess file. I actually force www. on all my URLs.

Also have some other funk though.

What’s the point of result_page=”search/results” if it always submits through the index? Anyway to force it through to a template?

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} ^findyourgeek\.com$ [NC]
RewriteRule (.*) http://www.findyourgeek.com/$1 [L,NE,R=301]

RewriteCond %{HTTP_USER_AGENT} ^Java [OR]
RewriteCond %{HTTP_USER_AGENT} ^libwww-perl [OR]
RewriteCond %{HTTP_USER_AGENT} (dts.?Agent¦Email.?Extrac)
RewriteRule .* - [F] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9\-\_]*)$ /profile.php?personalurl=$1 [L]
#RewriteRule ^([a-zA-Z0-9\-\_]*)/$ /profile.php?personalurl=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /ee.php?$1 [L]

ErrorDocument 404 /errors/404-not-found.php
       
Brandon Jones's avatar
Brandon Jones
5,500 posts
14 years ago
Brandon Jones's avatar Brandon Jones

Hi Tom,

Please test without forcing www. As an aside, the preferred way to do that is with a redirect rather than URL rewriting.

The behavior you’re seeing is correct (submitting through index.php) as that’s how module actions are executed. Once the search completes, you should be redirected to the template specified by the result_page parameter.

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Brandon,

If a rem out the lines that force www the same behavior still persists…form is submitted to index and just stops there.

Tom

       
Dan Decker's avatar
Dan Decker
7,338 posts
14 years ago
Dan Decker's avatar Dan Decker

Hi TomT,

I’m sorry this is still a problem for you. Can you reply with the template code for your results template? That my gives a clue to what’s causing the hangup.

Thanks,

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

On the page that I want users to be able to search from, I have the following code:

http://www.findyourgeek.com/reviews/

{exp:search:simple_form channel="movie_reviews" result_page="search/results" results="20" status="open"}
     <div class="search">
          <input type="text" class="searchBox" name="keywords" id="keywords" value="" maxlength="100" />
     </div>
{/exp:search:simple_form}

I created a template group called “search” and two templates called “index” and “results”.

There’s really nothing in them right now and you can see the results page here:

http://www.findyourgeek.com/search/results/

When the search is submitted it stops on my site’s index:

http://www.findyourgeek.com

The values are being submitted as if I refresh the browser tries to resubmit the form.

Thanks, Tom

       
Dan Decker's avatar
Dan Decker
7,338 posts
14 years ago
Dan Decker's avatar Dan Decker

Hi TomT,

Again, I’m sorry this is still an issue for you. Please be looking for an email from me. We’d like to get in there and take a look. If we can get hands-on, we should be able to sort this out more quickly.

Best,

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Ok, going to do a quick backup and then I’ll fill out that form.

       
Brandon Jones's avatar
Brandon Jones
5,500 posts
14 years ago
Brandon Jones's avatar Brandon Jones

Hi TomT,

I’m definitely in the dark about how your overall site is built, but it looks like the main index.php file serving your site isn’t ExpressionEngine per se (compare it to the same file included in the EE download). It’s pulling data from EE’s database, but it doesn’t have the code that routes action_ids to the appropriate module (e.g. the Search module). You can see for yourself if you try to go to, say

http://www.yourdomain.com/?URL=http://google.com

On a normal EE installation, that will redirect you to Google. On your site, the homepage comes up just like what you’re seeing with the Search module, because the EE code looking for the URL trigger isn’t there.

This is likely something you’ll need to discuss with your developer, as some of that custom code is not going to survive upgrades very well. Hope this points you in the right direction - we’ll leave this thread open for you.

       
TomT's avatar
TomT
49 posts
14 years ago
TomT's avatar TomT

Brandon,

My site was already live for a number of years before I added EE to it as a CMS for new content like the articles and reviews you see.

The EE submitted content you see on the index is actually code I wrote in pure PHP that queries the EE tables to get that info.

The pages at findyourgeek.com/articles and findyourgeek.com/reviews are the ones handled by EE exclusively.

So to answer your question, EE isn’t handling my index page but EE handles requests for pages like findyourgeek.com/articles/ just fine.

I’m extremely confused as to why the search doesn’t work, especially if I specify search/results as the results page. Why would it submit the form to the index if I specify a result_page?

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.